Re: [PROPOSAL] Covering + unique indexes. - Mailing list pgsql-hackers

From David Rowley
Subject Re: [PROPOSAL] Covering + unique indexes.
Date
Msg-id CAKJS1f_ApKpHn2B8YHQFx6mKBLadcC0+UFoeCiLetE-W+3A3_A@mail.gmail.com
Whole thread Raw
In response to [PROPOSAL] Covering + unique indexes.  (Anastasia Lubennikova <a.lubennikova@postgrespro.ru>)
Responses Re: [PROPOSAL] Covering + unique indexes.  (Anastasia Lubennikova <a.lubennikova@postgrespro.ru>)
List pgsql-hackers
On 12 September 2015 at 00:45, Anastasia Lubennikova <a.lubennikova@postgrespro.ru> wrote:
I've started work on a patch that allows to combine covering and unique functionality.

Great to hear someone is working on this!
 
Next issue is pg_index changes.
Now there's only a boolean flag
  • bool indisunique; /* is this a unique index? */
But new algorithm requires to store a single number
  • unit16 n_unique_columns; /* number of first columns of index which has unique constrains. */
I think, that numbers of all attributes themselves are not needed. Is it right?


I think the total number of attributes is already in indnatts. 
I imagine you're planning to keep the indexed columns at the start of the indkey[] array, and just use n_unique_columns to mark how many of the indkey[] attributes to check as indexed columns. I'd imagine the change would be fairly simple from a planner point of view as you'd just need to check columns 1 to  n_unique_columns instead of 1 to indnatts. Although I have a tendency to under estimate these things :(

I imagine you don't want to name the new column n_unique_columns, since it does not fit too well with non-unique indexes.
Perhaps just indindexedatts, or something slightly along those lines. But perhaps it would be a good idea to also rename "ncolumns" in code, to ensure that any non-updated code does not even compile. Perhaps including "tot" or "total" in there might help indicate it's new meaning.
 
Regards

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

pgsql-hackers by date:

Previous
From: Vik Fearing
Date:
Subject: Re: [PROPOSAL] Covering + unique indexes.
Next
From: Masahiko Sawada
Date:
Subject: Re: Summary of plans to avoid the annoyance of Freezing