From: | James Nelson <james(at)photoshelter(dot)com> |
---|---|
To: | Grzegorz Jaśkiewicz <gryzman(at)gmail(dot)com> |
Cc: | pgsql-performance(at)postgresql(dot)org |
Subject: | Re: bad plan and LIMIT |
Date: | 2009-05-01 15:07:50 |
Message-ID: | 58728725-13C7-4A47-9D6C-751193773C11@photoshelter.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | 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();
From | Date | Subject | |
---|---|---|---|
Next Message | Robert Haas | 2009-05-01 15:27:04 | Re: Transparent table partitioning in future version of PG? |
Previous Message | Tom Lane | 2009-05-01 14:57:40 | Re: bad plan and LIMIT |