James Nelson | 1 May 2009 17:07

Re: bad plan and LIMIT


The 'in' form and 'join' form produce identical plans for both limit  
and non-limit versions of the query, which I actually think reflects  
well on the query planner. I also tried a form of the query with the  
subselect in the from clause to try and force the order the tables  
were evaluated but the query planner saw through that one too.  
Basically this query:

SELECT ps_image.id FROM
	(SELECT image_id FROM ps_gallery_image WHERE  
gallery_id='G00007ejKGoWS_cY') as ids
INNER JOIN ps_image on ps_image.id = ids.image_id ORDER BY  
LOWER(FILE_NAME) ASC limit 1;

produces the same plan as the 'in' or the 'join' form when the limit  
clause is present.

  James

On May 1, 2009, at 4:32 AM, Grzegorz Jaƛkiewicz wrote:

> use join instead of where in();

--

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


Gmane