SPI cursors pinned buffer and moving to the first tuple.

From: Tzahi Fadida <tzahi_ml(at)myrealbox(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: SPI cursors pinned buffer and moving to the first tuple.
Date: 2005-04-28 01:06:28
Message-ID: 00c001c54b8e$84bc2850$0b00a8c0@llord
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi,
I need to verify something.
I use spi cursors in a C function (which return a SETOF).
I am using the spi cursors to run the following query:
"SELECT DISTINCT * FROM mytable".
Each time the system gets back to the function
spi cursor can give me the next tuple which I can return.
Q1:My question is, does an SPI cursor pin its last buffer,
I.e. if I will take 1 tuple from SPI each time and
a page can contain 10 tuples, would there be 10 I/Os
or just 1 (since the last page is always pinned in memory).

I tried to reason the answer from the code but its not as clear as
the heap_fetch,etc... functions.

Q2:If I move to the first tuple in the cursor, does it reads everything
in its way back? I don't want the database to start another SELECT
DISTINCT
and use what is already ready.

Thanks.

Regards,
tzahi.

WARNING TO SPAMMERS: see at
http://members.lycos.co.uk/my2nis/spamwarning.html

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2005-04-28 01:22:42 Re: I must be daft, but I can't figure out what is wrong with this
Previous Message Hrishikesh Deshmukh 2005-04-28 00:58:08 Visual Query Builder