Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qgeBE-00GbYh-Kb for pgsql-hackers@arkaria.postgresql.org; Thu, 14 Sep 2023 04:42:16 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1qgeBD-005dDz-Fa for pgsql-hackers@arkaria.postgresql.org; Thu, 14 Sep 2023 04:42:15 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qgeBD-005dDi-56 for pgsql-hackers@lists.postgresql.org; Thu, 14 Sep 2023 04:42:14 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qgeB9-004y91-9x for pgsql-hackers@lists.postgresql.org; Thu, 14 Sep 2023 04:42:14 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 38E4fwBi3063409; Thu, 14 Sep 2023 00:41:58 -0400 From: Tom Lane To: Erik Rijkers cc: "David E. Wheeler" , Erik Wienhold , pgsql-hackers@lists.postgresql.org Subject: Re: JSON Path and GIN Questions In-reply-to: References: <15DD78A5-B5C4-4332-ACFE-55723259C07F@justatheory.com> <133696180.303713.1694566807910@office.mailbox.org> <640942d7-c996-0562-62c9-d69a4c1f9b1e@xs4all.nl> Comments: In-reply-to Erik Rijkers message dated "Thu, 14 Sep 2023 06:04:28 +0200" MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-ID: <3063407.1694666518.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Thu, 14 Sep 2023 00:41:58 -0400 Message-ID: <3063408.1694666518@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Erik Rijkers writes: > p 9/13/23 om 22:01 schreef David E. Wheeler: >> On Sep 13, 2023, at 01:11, Erik Rijkers wrote: >>> "All use of json*() functions preclude index usage." >> Where did that come from? Why wouldn=E2=80=99t JSON* functions use inde= xes? I see that the docs only mention operators; why would the correspondi= ng functions behave the same? > Sorry, perhaps my reply was a bit off-topic. > But you mentioned perhaps touching the docs and > the not-use-of-index is just so unexpected. Unexpected to who? I think the docs make it pretty plain that only operators on indexed columns are considered as index qualifications. Admittedly, 11.2 Index Types [1] makes the point only by not discussing any other case, but when you get to 11.10 Operator Classes and Operator Families [2] and discover that the entire index definition mechanism is based around operators not functions, you should be able to reach that conclusion. The point is made even more directly in 38.16 Interfacing Extensions to Indexes [3], though I'll concede that that's not material I'd expect the average PG user to read. As far as json in particular is concerned, 8.14.4 jsonb Indexing [4] is pretty clear about what is or is not supported. regards, tom lane [1] https://www.postgresql.org/docs/current/indexes-types.html [2] https://www.postgresql.org/docs/current/indexes-opclass.html [3] https://www.postgresql.org/docs/current/xindex.html [4] https://www.postgresql.org/docs/current/datatype-json.html#JSON-INDEXI= NG