Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iDtFg-0000Va-IO for pgsql-docs@arkaria.postgresql.org; Fri, 27 Sep 2019 16:37:52 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1iDtFf-00032S-Ba for pgsql-docs@arkaria.postgresql.org; Fri, 27 Sep 2019 16:37:51 +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_SHA1:256) (Exim 4.89) (envelope-from ) id 1iDtFf-00032L-4n for pgsql-docs@lists.postgresql.org; Fri, 27 Sep 2019 16:37:51 +0000 Received: from momjian.us ([72.94.173.45]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iDtFc-00050c-GM for pgsql-docs@lists.postgresql.org; Fri, 27 Sep 2019 16:37:50 +0000 Received: from bruce by momjian.us with local (Exim 4.92) (envelope-from ) id 1iDtFb-0006Qs-5f; Fri, 27 Sep 2019 12:37:47 -0400 Date: Fri, 27 Sep 2019 12:37:47 -0400 From: Bruce Momjian To: tuomas.leikola@gmail.com, pgsql-docs@lists.postgresql.org Subject: Re: uniqueness and null could benefit from a hint for dba Message-ID: <20190927163747.GE31412@momjian.us> References: <156760275564.1127.12321702656456074572@wrigleys.postgresql.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <156760275564.1127.12321702656456074572@wrigleys.postgresql.org> User-Agent: Mutt/1.10.1 (2018-07-13) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On Wed, Sep 4, 2019 at 01:12:35PM +0000, PG Doc comments form wrote: > The following documentation comment has been logged on the website: > > Page: https://www.postgresql.org/docs/11/indexes-unique.html > Description: > > Sometimes it is convenient to create an unique index that considers NULL > values equal. Designating a "zero" value for those rows might not be > feasible, for example due to a foreign key. > > The documentation currently only states that unique indexes do not consider > NULLs equal. It might be good to offer workarounds, like indexing a coalesce > function, if scans are not the reason for the index, but the uniqueness > constraint. I did write a blog entry about this: https://momjian.us/main/blogs/pgblog/2017.html#April_3_2017 Does that help? -- Bruce Momjian http://momjian.us EnterpriseDB http://enterprisedb.com + As you are, so once was I. As I am, so you will be. + + Ancient Roman grave inscription +