Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jQcvD-0003iy-OJ for pgsql-docs@arkaria.postgresql.org; Mon, 20 Apr 2020 20:21:39 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1jQcvC-0006zP-FE for pgsql-docs@arkaria.postgresql.org; Mon, 20 Apr 2020 20:21:38 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jQcvC-0006zI-99 for pgsql-docs@lists.postgresql.org; Mon, 20 Apr 2020 20:21:38 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jQcv9-0000ol-IF for pgsql-docs@postgresql.org; Mon, 20 Apr 2020 20:21:37 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id 03KKLWNM008756; Mon, 20 Apr 2020 16:21:32 -0400 From: Tom Lane To: Bruce Momjian cc: PostgreSQL-documentation Subject: Re: pgsql: doc: add examples of creative use of unique expression indexes In-reply-to: <20200411122532.GE24988@momjian.us> References: <2304.1586532634@sss.pgh.pa.us> <20200410214821.GC24988@momjian.us> <13031.1586560889@sss.pgh.pa.us> <20200411001709.GD24988@momjian.us> <20200411122532.GE24988@momjian.us> Comments: In-reply-to Bruce Momjian message dated "Sat, 11 Apr 2020 08:25:32 -0400" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <8754.1587414092.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Mon, 20 Apr 2020 16:21:32 -0400 Message-ID: <8755.1587414092@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk [ sorry, I'd lost track of this thread ] Bruce Momjian writes: > I now remember that I wrote the first IS NULL in: > CREATE UNIQUE INDEX tests_target_one_null ON tests ((target IS NULL)) = WHERE target IS NULL; > in hope that if someone is looking for the null value in the column, the > IS NULL would allow the index to be used to find it, while 1 or true > would not. Well, that's not the case: regression=3D# create index tenk1_null_index on tenk1((1)) where ten is nu= ll; CREATE INDEX regression=3D# explain select * from tenk1 where ten is null; QUERY PLAN = = --------------------------------------------------------------------------= ------ Index Scan using tenk1_null_index on tenk1 (cost=3D0.12..8.14 rows=3D1 w= idth=3D244) (1 row) (Maybe it was true at some time in the past, but not any more.) Also, it complicates the example, and since you didn't explain the reason for the complication, I think it's pretty confusing. But really I still don't see the need for these additional examples at all. It's especially weird that what you want to do is have some examples on that page have markup and others not. regards, tom lane