"Hell, Robert" <Robert.Hell@xxxxxxxxxxxx> writes: > When we use 20 as default_statistics_target the retrieval of the data > takes 7.5 seconds - with 25 as default_statistics_target (with restart > and analyze) it takes 0.6 seconds. > The query plan is identical in both situations (row estimation differs a > little bit) - the query is always fast when it is executed without a > cursor. A cursor doesn't necessarily use the same plan as a straight query does. Try "EXPLAIN DECLARE curs_285058224 CURSOR FOR ..." and see if you aren't getting different plans in these two cases. regards, tom lane -- Sent via pgsql-performance mailing list (pgsql-performance@xxxxxxxxxxxxxx) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-performance