Andrey Chursin <andll(at)danasoft(dot)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