> I am also very interesting in this very question.. Is there any way to
> declare a persistant cursor that remains open between pg sessions?
> This would be better than a temp table because you would not have to
> do the initial select and insert into a fresh table and incur those IO
> costs, which are often very heavy, and the reason why one would want
> to use a cursor.
Yes, it's called a 'view' :-)
Everything you can do with cursors you can do with a view, including
selecting records in blocks in a reasonably efficient way. As long as
your # records fetched is not real small (> 10) and your query is not
super complex, you can slide your view just like a cursor with zero real
impact on performance.
If the query in question does not scale in time complexity with the
amount of data returned (there is a fix processing step which can't be
avoided), then it's materialized view time, such that they can be done
Now, cursors can be passed around in pl/pgsql functions which makes them
very useful in that context. However, for normal data processing via
queries, they have some limitations that makes them hard to use in a
pgsql-performance by date
|Next:||From: Randolf Richardson||Date: 2005-01-20 17:00:51|
|Subject: Re: PostgreSQL vs. Oracle vs. Microsoft|
|Previous:||From: Greg Stark||Date: 2005-01-20 16:59:34|
|Subject: Re: [SQL] OFFSET impact on Performance???|