From: | Mario Splivalo <mario(dot)splivalo(at)megafon(dot)hr> |
---|---|
To: | pgsql-performance(at)postgresql(dot)org |
Subject: | Re: Planner choosing NestedLoop, although it is slower... |
Date: | 2011-07-13 02:04:35 |
Message-ID: | 4E1CFD33.7040407@megafon.hr |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-performance |
On 07/13/2011 02:53 AM, Mario Splivalo wrote:
> On 07/13/2011 12:39 AM, Tom Lane wrote:
>> Mario Splivalo<mario(dot)splivalo(at)megafon(dot)hr> writes:
>>> On 07/12/2011 10:04 PM, Tom Lane wrote:
>>>> What you need to look into is why the estimated join size is 9400 rows
>>>> when the actual join size is zero. Are both tables ANALYZEd? Are you
>>>> intentionally selecting rows that have no join partners?
>>
>>> Yes, both tables have been ANALYZEd. What do you mean, intentilnaly
>>> selecting rows taht have no join partners?
>>
>> I'm wondering why the actual join size is zero. That seems like a
>> rather unexpected case for a query like this.
>
> Yes, seems that planer gets confused by LIMIT. This query:
>
> select * from tubesite_object join tubesite_image on id=object_ptr_id
> where site_id = 8 and pub_date < '2011-07-12 13:25:00' order by pub_date
> desc ;
>
> Does not choose Nested Loop, and is done instantly (20 ms), and returns
> no rows. However, if I add LIMIT at the end, it chooses NestedLoop and
> it takes 500ms if I'm alone on the server, and 10+ seconds if there 50+
> connections on the server.
As explained/suggested by RhodiumToad on IRC, adding composite index on
(site_id, pub_date) made nestedloop query finish in around 100 seconds!
Thank you!
Mario
From | Date | Subject | |
---|---|---|---|
Next Message | Lars | 2011-07-13 04:01:34 | Re: UPDATEDs slowing SELECTs in a fully cached database |
Previous Message | Tom Lane | 2011-07-13 01:16:37 | Re: UPDATEDs slowing SELECTs in a fully cached database |