Re: Weird query plans for my queries, causing terrible performance. - Mailing list pgsql-general

From Tom Lane
Subject Re: Weird query plans for my queries, causing terrible performance.
Date
Msg-id 8771.1044027032@sss.pgh.pa.us
Whole thread Raw
In response to Re: Weird query plans for my queries,  (Arjen van der Meijden <acm@tweakers.net>)
List pgsql-general
Arjen van der Meijden <acm@tweakers.net> writes:
> That is weird, a copy&paste of your command into my psql results in:
> [different results]

Hm, there must be some difference on this query between 7.3 and CVS tip
then; I was not expecting that.  [ ... a debugger is fired up ... time
passes ... ]

Ah hah.  There's a rather shaky heuristic in canonicalize_qual that
prefers DNF if certain things are true, one of them being that the
qual condition mentions only one relation.  This test is being fooled
because you wrote some of the variables with "F_Topics." and some
without (which means that, according to the letter of the SQL spec,
they refer to the join relation's result and not the original table).
I find that 7.3 will produce the desired plan if I write all the
variables in the WHERE clause the same way, either with or without
"F_Topics.".  CVS tip doesn't show this effect because it handles join
variables differently.

So that's your workaround for the moment.  As I was saying, this code
could use some fresh ideas...

            regards, tom lane

pgsql-general by date:

Previous
From: Joep DeVocht
Date:
Subject: Clearing tables questions
Next
From: Arjen van der Meijden
Date:
Subject: Re: Basic SQL join question