From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | "Michal J(dot) Kubski" <michal(dot)kubski(at)cdt(dot)pl> |
Cc: | pgsql-performance(at)postgresql(dot)org |
Subject: | Re: query planning different in plpgsql? |
Date: | 2009-10-23 16:20:18 |
Message-ID: | 11906.1256314818@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-performance |
On Fri, Oct 23, 2009 at 11:38 AM, Michal J. Kubski <michal(dot)kubski(at)cdt(dot)pl>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
From | Date | Subject | |
---|---|---|---|
Next Message | Richard Huxton | 2009-10-23 16:27:54 | Re: Queryplan within FTS/GIN index -search. |
Previous Message | Jeff Davis | 2009-10-23 16:01:02 | Re: Queryplan within FTS/GIN index -search. |