Re: [GENERAL] Very slow queries w/ NOT IN preparation (seems like a bug, test case)

From: Richard Huxton <dev(at)archonet(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Sergey Konoplev <gray(dot)ru(at)gmail(dot)com>, pgsql-hackers(at)postgreSQL(dot)org
Subject: Re: [GENERAL] Very slow queries w/ NOT IN preparation (seems like a bug, test case)
Date: 2008-11-12 16:29:34
Message-ID: 491B046E.1070208@archonet.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-hackers

Tom Lane wrote:
> "Sergey Konoplev" <gray(dot)ru(at)gmail(dot)com> writes:
>> You are right. I've found the odd thing (that completely drives me
>> mad) in postgresql.conf.
>
>> You are able to reproduce slow-not-in queries by switching
>> constraint_exclusion to on in your postgresql.conf and running my test
>> (which is attached to the first message).
>
> Hmph. It's trying to see if the NOT IN condition is self-contradictory,
> which of course it isn't, but the predicate_refuted_by machinery isn't
> smart enough to determine that except by running through all N^2
> combinations of the individual x <> const conditions :-(.

So it's not checking the table, it's looking to see whether <clause1> OR
<clause2> end up excluding each other? Presumably becuase "OR" is just
another operator?

> We could respond to this in a number of ways:
>
> 1. "Tough, don't do that."
>
> 2. Put some arbitrary limit on the number of subconditions in an AND or
> OR clause before we give up and don't attempt to prove anything about
> it.

Do we know the estimated cost of just executing the planner-node at this
point? You could scale with the cost of actually doing the tests.

> 3. Put in a narrow hack that will get us out of this specific case,
> but might still allow very slow proof attempts in other large cases.
>
> The specific narrow hack I'm considering for #3 goes like this:

The specific hack goes right over my head :-)

--
Richard Huxton
Archonet Ltd

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Robert Fitzpatrick 2008-11-12 16:55:45 Post to another db using pl/pgsql
Previous Message Tom Lane 2008-11-12 16:17:03 Re: sequence not restarting in a for loop (actually semi-random numbers)

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Eisentraut 2008-11-12 16:57:32 Re: TABLE command
Previous Message Heikki Linnakangas 2008-11-12 16:21:43 Re: Optimizing COPY