On Fri, Oct 23, 2009 at 11:38 AM, Michal J. Kubski <michal.kubski@xxxxxx>wrote: >> I am running the following one and it takes 10 minutes in the procedure >> when it is pretty fast standalone. >> >> # EXPLAIN ANALYZE SELECT m.domain_id, nsr_id FROM nsr_meta m, last_snapshot >> l WHERE m.domain_id = l.domain_id; Is it *really* just like that inside the stored procedure? Usually the reason for a difference in plan is that the procedure's query references some variables of the procedure, which people think act like constants but they don't. Also, if you're executing the SELECT as a plpgsql FOR-loop, it will be planned like a cursor, so the thing to compare against is explain [analyze] declare x cursor for select ... 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