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

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Heikki Linnakangas <heikki(dot)linnakangas(at)enterprisedb(dot)com>
Cc: Brendan Jurd <direvus(at)gmail(dot)com>, Richard Huxton <dev(at)archonet(dot)com>, 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 21:09:19
Message-ID: 20938.1226524159@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-hackers

Heikki Linnakangas <heikki(dot)linnakangas(at)enterprisedb(dot)com> writes:
> Which brings to mind an interesting customer case. They are running
> queries like "WHERE id IN (...)", where ... is a *very* long list of
> keys, against a table that's partitioned by ranges of id. The query was
> running slow, because while constraint exclusion was able to eliminate
> completely useless partitions, if there was even one id in the list that
> falls into a given partition, the partition was probed for *all* of the
> ids, even those that belong to other partitions. Ideally, we would not
> only prove/refute the whole "x = ANY" expression, but individual values
> within it.

> Actually, the long list of keys was obtained by running another query
> first. They originally had a single query with a join, but they split it
> to two queries because constraint exclusion doesn't work at run-time..

Yeah, at some point (after we have an explicit notion of partitioning in
the system, instead of the current build-it-from-spare-parts approach)
we ought to look at managing this stuff at runtime rather than expecting
that exclusion can be proven at plan time. In particular a plan type
that acted like an indexscan across the whole partitioned table (select
proper partition, then indexscan) would be real handy.

regards, tom lane

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Roderick A. Anderson 2008-11-12 21:22:19 Re: Using dblink to connect as non-superuser
Previous Message Robert Fitzpatrick 2008-11-12 21:04:59 Using dblink to connect as non-superuser

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2008-11-12 21:25:44 Re: Reducing some DDL Locks to ShareLock
Previous Message Gregory Stark 2008-11-12 20:38:33 Re: Block-level CRC checks