Re: Weird query plan

From: Dmitry Tkach <dmitry(at)openratings(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pg_general <pgsql-general(at)postgresql(dot)org>
Subject: Re: Weird query plan
Date: 2003-09-17 21:54:05
Message-ID: 3F68D7FD.1020300@openratings.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Tom Lane wrote:

>Dmitry Tkach <dmitry(at)openratings(dot)com> writes:
>
>
>>>Hm. You know, I wonder whether the query plans really are the same.
>>>One of the reasons why 7.3 and later show the qual conditions is that
>>>it was too easy to fall into the trap of assuming that plans of the same
>>>structure had the same conditions. Try doing "explain verbose" and look
>>>to see if the plans look the same at that level of detail.
>>>
>>>
>
>
>
>>I am afraid that's too much detail for me to look at :-)
>>I have no clue what all that stuff means :-(
>>
>>
>
>Well, "diff" would've been enough to tell you they are different. It
>looks to me like in the slow case the query plan is of the form
>
>Limit
> -> Nested Loop
> -> Index Scan using a_pkey on a
> <<no index condition, ie full table scan>>
> -> Index Scan using b_pkey on b
> b.id >= 7901288 and b.id = "outer".id
>
>which is a pretty silly plan to arrive at; are you by any chance running
>with enable_seqscan = off?
>
Ummm... yes, I am.
Sorry, I should have mentioned that earlier...

>
>I'm not certain why 7.2 would be picking this plan, esp. given that it
>is capable of generating the better plan. It might be that it's got
>something to do with the low selectivity of the id >= 7901288 clause.
>In any case, if it's fixed in 7.3 I'm not going to worry too much about
>it ...
>
>
>
I don't know that actually - the 7.3 database I tried it on when it
worked was empty .... I just assumed, that since it generated the right
query plan it would work...
But then, I fugured out that it worked in 7.2 as well when I tried it
with just two empty tables :-(

Dima

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Ron Johnson 2003-09-17 21:56:40 High-volume shop uses PostgreSQL
Previous Message Tom Lane 2003-09-17 21:37:57 Re: Weird query plan