Re: Fetch from cursor with indexed sorting - Mailing list pgsql-general

From Tom Lane
Subject Re: Fetch from cursor with indexed sorting
Date
Msg-id 20193.1331823160@sss.pgh.pa.us
Whole thread Raw
In response to Fetch from cursor with indexed sorting  (Andrey Chursin <andll@danasoft.ws>)
List pgsql-general
Andrey Chursin <andll@danasoft.ws> writes:
> I need to create cursor, open it, fetch records one-by-one and
> aggregate. Then on some condition I stop fetching and return
> aggregated value. In fact in most cases my procedure scans a little
> part of table.

> But does postgres understand such usage of index and cursors?

Not unless you tell it.  You may need to reduce the value of
cursor_tuple_fraction to inform the planner that you're only expecting
to fetch a small part of the cursor's theoretical output.

            regards, tom lane

pgsql-general by date:

Previous
From: Tom Lane
Date:
Subject: Re: yum repository packages 9.0 and 9.1 libpq conflict
Next
From: "Albe Laurenz"
Date:
Subject: Re: Backups