Re: bad plan and LIMIT - Mailing list pgsql-performance

From James Nelson
Subject Re: bad plan and LIMIT
Date
Msg-id 58728725-13C7-4A47-9D6C-751193773C11@photoshelter.com
Whole thread Raw
In response to Re: bad plan and LIMIT  (Grzegorz Jaśkiewicz <gryzman@gmail.com>)
List pgsql-performance
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();


pgsql-performance by date:

Previous
From: James Nelson
Date:
Subject: Re: bad plan and LIMIT
Next
From: Robert Haas
Date:
Subject: Re: Transparent table partitioning in future version of PG?