Skip site navigation (1) Skip section navigation (2)

Re: Limiting the number of parameterized indexpaths created

From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Limiting the number of parameterized indexpaths created
Date: 2012-11-05 20:19:01
Message-ID: CA+Tgmoa7BoiTpkxS_0D5sJkM6_1xSFkq_gD47_8YY6pheqtXVg@mail.gmail.com (view raw or flat)
Thread:
Lists: pgsql-hackers
On Mon, Nov 5, 2012 at 3:07 PM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> Robert Haas <robertmhaas(at)gmail(dot)com> writes:
>> On Mon, Nov 5, 2012 at 2:44 PM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
>>> Um, no.  This is a useful counterexample:
>>>      WHERE t.a > x.c1 AND t.a < y.c2
>
>> Well, OK.  So maybe you also need the operator to be the same as well.
>
> Nope.  A counterexample to that claim is a GIN index on an array column:
>
>         WHERE t.arraycol @> array[1,2,3] AND t.arraycol @> array[4,5,6]
>
> This restriction is equivalent to
>
>         WHERE t.arraycol @> array[1,2,3,4,5,6]
>
> which is substantially more selective than either constraint alone.
> If the two RHS arrays are not constants, but are coming from different
> tables x and y, then we have something isomorphic to the previous
> example (at least from the perspective of indxpath.c), but it would
> not be good for indxpath.c to assume that these clauses couldn't be
> useful together.

Neat example.

> We *can* make a simplifying assumption of the kind you suggest when
> we know that the clauses were all generated from the same equivalence
> class, because then we have very strong assumptions about what the
> clauses' semantics are.  (And indeed the patch does take care of that
> case separately.)  But for the general case of non-equijoin clauses
> we can't assume very much at all about whether clauses are redundant,
> at least not without knowledge that indxpath.c hasn't got.

OK.  Fortunately, I don't think we need to care too much about that
case, since non-equijoins are pretty rare.  A reasonable heuristic
restriction seems fine for that case ... at least until the next
problem case shows up.

-- 
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company


In response to

pgsql-hackers by date

Next:From: Magnus HaganderDate: 2012-11-05 20:23:04
Subject: Re: Pg_upgrade speed for many tables
Previous:From: Tom LaneDate: 2012-11-05 20:14:40
Subject: Re: Pg_upgrade speed for many tables

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group