Skip site navigation (1) Skip section navigation (2)

Re: query planning different in plpgsql?

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 (view raw or flat)
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

In response to

pgsql-performance by date

Next:From: Richard HuxtonDate: 2009-10-23 16:27:54
Subject: Re: Queryplan within FTS/GIN index -search.
Previous:From: Jeff DavisDate: 2009-10-23 16:01:02
Subject: Re: Queryplan within FTS/GIN index -search.

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group