Received: from malur.postgresql.org ([2a02:16a8:dc51::56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fnhuZ-0000xL-1H for pgsql-hackers@arkaria.postgresql.org; Thu, 09 Aug 2018 10:11:19 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1fnhuX-0004Be-B8 for pgsql-hackers@arkaria.postgresql.org; Thu, 09 Aug 2018 10:11:17 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fnhuW-0004BW-Tr for pgsql-hackers@lists.postgresql.org; Thu, 09 Aug 2018 10:11:17 +0000 Received: from forward4p.cmail.yandex.net ([77.88.31.19]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fnhuR-0005nJ-Lj for pgsql-hackers@postgresql.org; Thu, 09 Aug 2018 10:11:15 +0000 Received: from mxback6g.mail.yandex.net (mxback6g.mail.yandex.net [IPv6:2a02:6b8:0:1472:2741:0:8b7:167]) by forward4p.cmail.yandex.net (Yandex) with ESMTP id 86C182111A; Thu, 9 Aug 2018 13:11:06 +0300 (MSK) Received: from localhost (localhost [::1]) by mxback6g.mail.yandex.net (nwsmtp/Yandex) with ESMTP id 6HfyjQMOpi-B5MOOptg; Thu, 09 Aug 2018 13:11:05 +0300 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex.ru; s=mail; t=1533809465; bh=SG3uK/G8I092UpTDouHydWOK6zVtgtsnKCGAIpdWpzc=; h=From:To:Cc:In-Reply-To:References:Subject:Date:Message-Id; b=LTVx0tSQxa1SB2C++787b7BRFM7MizfnUgCY+jOzl85AVlcPuwWODTCHHrzteD4id VCZu+LIViv3m+rpXkJw4IwNkl0BLAnlY7hP0BrGVY77QISm+MlALoAb4cMhzYsTkLy sA36NEkb47XKGU7k77mujbs8qsNJ+/Q/gM5LQDvo= Authentication-Results: mxback6g.mail.yandex.net; dkim=pass header.i=@yandex.ru Received: by sas1-87f9feb8d943.qloud-c.yandex.net with HTTP; Thu, 09 Aug 2018 13:11:05 +0300 From: KES Envelope-From: kes-kes@yandex.com To: Tom Lane , Bruce Momjian Cc: PostgreSQL-development In-Reply-To: <12107.1533736288@sss.pgh.pa.us> References: <153121527691.1408.5686988620817799073@wrigleys.postgresql.org> <20180807173659.GD7297@momjian.us> <31616681533725753@sas1-d856b3d759c7.qloud-c.yandex.net> <20180808130040.GA2611@momjian.us> <12107.1533736288@sss.pgh.pa.us> Subject: Re: Typo in doc or wrong EXCLUDE implementation MIME-Version: 1.0 X-Mailer: Yamail [ http://yandex.ru ] 5.0 Date: Thu, 09 Aug 2018 13:11:05 +0300 Message-Id: <37593701533809465@sas1-87f9feb8d943.qloud-c.yandex.net> Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=utf-8 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Bruce: >Yes, it would work, but doing that only for equality would be surprising to many people Why surprising? It is [documented](https://www.postgresql.org/docs/current/static/sql-createtable.html#sql-createtable-exclude): >If all of the specified operators test for equality, this is equivalent to a UNIQUE constraint, although an ordinary unique constraint will be faster. Thus the UNIQUE constraint is just particular case of exclusion constraint, is not? Tom >It's less efficient (1) and less portable Yes, portability has matter, but more general SQL would be more efficient at developer hours to support such application in compare to writing many particular SQL's (one SQL expression is better than two which do same job). Personally I would close the eyes on portability in favor of using modern features (looking forward for inclusion constraint) For speed efficiency (1) this particular case of exclusion constraint can be implemented via btree-based uniqueness. (like uniqueness is implemented via indexes under the hood. but the implementaion details have no matter as for me) 08.08.2018, 16:51, "Tom Lane" : > Bruce Momjian writes: >>  On Wed, Aug 8, 2018 at 01:55:53PM +0300, KES wrote: >>>  If such exclusion constraint would be marked as UNIQUE we can use it for FK while implementing temporal/bi-temporal tables. > >>  Yes, it would work, but doing that only for equality would be surprising >>  to many people because exclusion constraints are more general than >>  equality comparisons. > > In general, we should be discouraging people from using EXCLUDE syntax > with simple equality operators, not encouraging them to do so. It's > less efficient and less portable than a regular btree-based uniqueness > constraint. So I think this proposal is a bad idea regardless of > whether it'd be technically feasible or not. > >                         regards, tom lane