Re: [PERFORM] Slow cursor

2011-10-26 Thread Andres Freund
Hi,

On Wednesday 26 Oct 2011 14:43:08 Cezariusz Marek wrote:
> Is there any known problem with slow cursors in PostgreSQL 8.4.5?
> 
> I have a following query, which is slow (on my database it takes 11 seconds
> to execute), probably should be rewritten, but it doesn't matter here. The
> problem is, that in cursor, each fetch takes much longer (even few
> minutes!), while only the first one should be slow. Am I doing something
> wrong?
Does the problem persist if you play around with cursor_tuple_fraction?

Andres

-- 
Sent via pgsql-performance mailing list (pgsql-performance@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-performance


Re: [PERFORM] Slow cursor

2011-10-26 Thread Cezariusz Marek
Gregg Jaskiewicz wrote:
> Do you really need to query the catalogues ? That on its own is not a
> good idea if you want something to run fast and frequently.

I know, but I've used it just to show the problem with cursors. I have the same 
problem
with other slow queries, which execute within x seconds in psql or pgAdmin, but 
for loops
in functions it takes at least x seconds to fetch each row. So please just 
imagine, that
it's an other slow query.

-- 

Cezariusz Marek   mob: +48 608 646 494
http://www.comarch.com/   tel: +48 33 815 0734



-- 
Sent via pgsql-performance mailing list (pgsql-performance@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-performance


Re: [PERFORM] Slow cursor

2011-10-26 Thread Gregg Jaskiewicz
Do you really need to query the catalogues ? That on its own is not a
good idea if you want something to run fast and frequently.


-- 
GJ

-- 
Sent via pgsql-performance mailing list (pgsql-performance@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-performance


Re: [PERFORM] slow cursor

2006-04-17 Thread Luckys
This is one thing that I always try to avoid, a single INSERT INTO...SELECT ...FROM or single UPDATE is always faster compared to looping the same within a cursor, unless its inevitable.
 
regards,
Luckys. 
On 4/17/06, Sriram Dandapani <[EMAIL PROTECTED]> wrote:



Hi
 
I have a cursor that fetches 150K rows and updates or inserts a table with 150K rows.
 
It takes several minutes for the process to complete (about 15 minutes). The select by itself (without cursor) gets all rows in 15 seconds.

 
Is there a way to optimize the cursor to fetch all records and speed up the process. I still need to do the record by record processing