Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1ZbYAv-000858-6q for pgsql-hackers@arkaria.postgresql.org; Mon, 14 Sep 2015 18:08:21 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84) (envelope-from ) id 1ZbYAu-0007rF-Iy for pgsql-hackers@arkaria.postgresql.org; Mon, 14 Sep 2015 18:08:20 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84) (envelope-from ) id 1ZbYAt-0007qS-9D for pgsql-hackers@postgresql.org; Mon, 14 Sep 2015 18:08:19 +0000 Received: from hook.sigaev.ru ([93.180.27.50]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84) (envelope-from ) id 1ZbYAp-000516-Lc for pgsql-hackers@postgresql.org; Mon, 14 Sep 2015 18:08:18 +0000 Received: from zorg.sigaev.ru (89-178-7-103.broadband.corbina.ru [89.178.7.103]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: teodor) by hook.sigaev.ru (Postfix) with ESMTPSA id DED2FB1918A; Mon, 14 Sep 2015 21:08:14 +0300 (MSK) Message-ID: <55F70D0A.2030503@sigaev.ru> Date: Mon, 14 Sep 2015 21:08:10 +0300 From: Teodor Sigaev User-Agent: Mozilla/5.0 (X11; FreeBSD i386; rv:36.0) Gecko/20100101 Firefox/36.0 SeaMonkey/2.33.1 MIME-Version: 1.0 To: Jim Nasby , Anastasia Lubennikova , pgsql-hackers Subject: Re: [PROPOSAL] Covering + unique indexes. References: <55F2C1BC.3010109@postgrespro.ru> <55F2CCD0.7040608@postgrespro.ru> <55F6F7AD.4080307@BlueTreble.com> In-Reply-To: <55F6F7AD.4080307@BlueTreble.com> Content-Type: text/plain; charset=KOI8-R; format=flowed Content-Transfer-Encoding: 7bit X-Pg-Spam-Score: -1.9 (-) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-hackers Precedence: bulk Sender: pgsql-hackers-owner@postgresql.org >> 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