Re: [PROPOSAL] Covering + unique indexes.

From: David Rowley <david(dot)rowley(at)2ndquadrant(dot)com>
To: Nicolas Barbier <nicolas(dot)barbier(at)gmail(dot)com>
Cc: Teodor Sigaev <teodor(at)sigaev(dot)ru>, Jim Nasby <Jim(dot)Nasby(at)bluetreble(dot)com>, Thomas Munro <thomas(dot)munro(at)enterprisedb(dot)com>, Anastasia Lubennikova <a(dot)lubennikova(at)postgrespro(dot)ru>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: [PROPOSAL] Covering + unique indexes.
Date: 2015-09-15 12:02:40
Message-ID: CAKJS1f9xKx8av-q0D_Zw7Xc1kUE5BKA8O7W9DN9+11eqTeUuyg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 15 September 2015 at 23:51, Nicolas Barbier <nicolas(dot)barbier(at)gmail(dot)com>
wrote:

> 2015-09-15 David Rowley <david(dot)rowley(at)2ndquadrant(dot)com>:
>
> > I'm also a bit confused where f3 comes in here. If it's UNIQUE on (f1,f2)
> > and we include f4. Where's f3?
>
> Columns f1, f2, f3 are in the internal nodes of the tree (i.e., they
> are used to find the ultimate leaf nodes). f4 is only in the leaf
> nodes. If f4 are typically big values, and they are typically not used
> in the search predicate, it makes the upper part of the index (which
> determines how many levels the index has) larger for no good reason.
> f4 can still be retrieved without going to the heap, so including it
> in the leaf nodes makes it possible to do index-only scans more often.
>
>
Hmm, ok, I guess I was unable to see any advantage to having f3 in the
btree, if it's not to be enforced as part of the unique constraint.
I now see that this is probably to allow pre-sorted paths without having to
enforce uniqueness over all of the indexed columns.

If that's the case then I assume that we'd also want something to allow
that to be done when creating a PRIMARY KEY constraint

Regards

David Rowley

--
David Rowley http://www.2ndQuadrant.com/
<http://www.2ndquadrant.com/>
PostgreSQL Development, 24x7 Support, Training & Services

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Jim Nasby 2015-09-15 12:57:21 Re: Can extension build own SGML document?
Previous Message Sameer Thakur-2 2015-09-15 12:02:13 Re: Support for N synchronous standby servers - take 2