Re: [PROPOSAL] Covering + unique indexes.

From: Teodor Sigaev <teodor(at)sigaev(dot)ru>
To: Jim Nasby <Jim(dot)Nasby(at)BlueTreble(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-14 18:08:10
Message-ID: 55F70D0A.2030503@sigaev.ru
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

>> CREATE INDEX index ON table (c1, c2, c3) UNIQUE ON (c1, c3);
>>
>> CREATE [UNIQUE {ON FIRST {COLUMN | n_unique_column COLUMNS}} INDEX ON
>> table_name (column_name1, column_name2 ...);
>
> I would use the first (simple) syntax and just throw an error if the
> user tries to skip a column on the UNIQUE clause.
Seems, second option looks as more natural extension of CREATE UNIQUE INDEX

>
> Have you by chance looked to see what other databases have done for
> syntax? I'm guessing this isn't covered by ANSI but maybe there's
> already an industry consensus.

MS SQL and DB/2 suggests (with changes for postgresql):
CREATE UNIQUE INDEX i ON t (a,b) INCLUDE (c)

MS SQL supports both unique and non-unique indexes, DB/2 only unique
indexes. Oracle/MySQL doesn't support covering indexes. Readed at
http://use-the-index-luke.com/sql/clustering/index-only-scan-covering-index

MSSQL/DB/2 variants looks good too.

--
Teodor Sigaev E-mail: teodor(at)sigaev(dot)ru
WWW: http://www.sigaev.ru/

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Thomas Munro 2015-09-14 18:50:00 Re: [PROPOSAL] Covering + unique indexes.
Previous Message Alvaro Herrera 2015-09-14 18:02:51 Re: Attach comments to functions' parameters and return value