Re: Fetch from cursor with indexed sorting

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Andrey Chursin <andll(at)danasoft(dot)ws>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Fetch from cursor with indexed sorting
Date: 2012-03-15 14:52:40
Message-ID: 20193.1331823160@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

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

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Albe Laurenz 2012-03-15 15:30:24 Re: Backups
Previous Message Tom Lane 2012-03-15 14:27:09 Re: yum repository packages 9.0 and 9.1 libpq conflict