pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Teodor Sigaev <teodor@sigaev.ru>
To: Jim Nasby <Jim.Nasby@BlueTreble.com>
To: Anastasia Lubennikova <a.lubennikova@postgrespro.ru>
To: pgsql-hackers <pgsql-hackers@postgresql.org>
Subject: Re: [PROPOSAL] Covering + unique indexes.
Date: Mon, 14 Sep 2015 21:08:10 +0300
Message-ID: <55F70D0A.2030503@sigaev.ru> (raw)
In-Reply-To: <55F6F7AD.4080307@BlueTreble.com>
References: <55F2C1BC.3010109@postgrespro.ru>
	<55F2CCD0.7040608@postgrespro.ru>
	<55F6F7AD.4080307@BlueTreble.com>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-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@sigaev.ru
                                       WWW: http://www.sigaev.ru/


-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers



view thread (35+ messages)  latest in thread

Message-ID: <55F70D0A.2030503@sigaev.ru>
Permalink:  ../55F70D0A.2030503@sigaev.ru/
Also on:    postgresql.org/message-id/55F70D0A.2030503@sigaev.ru

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-hackers@postgresql.org
  Cc: teodor@sigaev.ru, Jim.Nasby@BlueTreble.com, a.lubennikova@postgrespro.ru
  Subject: Re: [PROPOSAL] Covering + unique indexes.
  In-Reply-To: <55F70D0A.2030503@sigaev.ru>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox