Cursors or Offset, Limit?

Started by Jerry LeVanover 20 years ago2 messagesgeneral
Jump to latest
#1Jerry LeVan
jerry.levan@eku.edu

Hi,

I am mucking around trying to build a gui'sh "table editor" for
Postgresql.

I am currently using a "held" cursor to move around the table, Since the
"cursor" does not show table modification I am thinking about using the
"limit" and "offset" attributes to select the rows to display.

What are some of the tradeoffs between using a cursor and using the
limit/offset method of selecting rows to display?

Thanks,

Jerry

#2Andrew Sullivan
ajs@crankycanuck.ca
In reply to: Jerry LeVan (#1)
Re: Cursors or Offset, Limit?

On Tue, Nov 15, 2005 at 01:44:32PM -0500, Jerry LeVan wrote:

What are some of the tradeoffs between using a cursor and using the
limit/offset method of selecting rows to display?

OFFSET actually has to scan all the preceding rows every time (plus
to get it consistently, you need to do an ORDER BY), so it's fast at
first but possibly painfully slow in the last rows (especially on a
large table).

A

--
Andrew Sullivan | ajs@crankycanuck.ca
A certain description of men are for getting out of debt, yet are
against all taxes for raising money to pay it off.
--Alexander Hamilton