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 1qgdYT-00GYMu-0R for pgsql-hackers@arkaria.postgresql.org; Thu, 14 Sep 2023 04:02:13 +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 1qgdYQ-005Onz-II for pgsql-hackers@arkaria.postgresql.org; Thu, 14 Sep 2023 04:02:10 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qgdYQ-005Onm-4W for pgsql-hackers@lists.postgresql.org; Thu, 14 Sep 2023 04:02:09 +0000 Received: from ewsoutbound.kpnmail.nl ([195.121.94.184]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qgdYL-004S6e-Qb for pgsql-hackers@lists.postgresql.org; Thu, 14 Sep 2023 04:02:08 +0000 X-KPN-MessageId: 71868aa2-52b3-11ee-b452-005056994fde Received: from smtp.kpnmail.nl (unknown [10.31.155.7]) by ewsoutbound.so.kpn.org (Halon) with ESMTPS id 71868aa2-52b3-11ee-b452-005056994fde; Thu, 14 Sep 2023 06:01:55 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=xs4all.nl; s=xs4all01; h=content-type:from:to:subject:mime-version:date:message-id; bh=+fwyjKuzRrklkvyxd8kl1etKHi7MMTA0rb166pPq85w=; b=VgX5YfY3oForBj652kuZk6pluPHTeeOUWCxJqgWYnyo8UVceDaDuKRSgQODOwtOuF79VawT+dLsru KhOaCTiLff2ivdbRHitSVpcWtOQzp5WtHy3F9cVT/mORJgfih/81GDiosbU1kAXDV9ExCFImAQDF0x gTNKBfV8s/nZtDsRM+4vDkZJwiPrR+ZFAxfOw8YHxvm8J+Gbhf8H/V+h32TFiseNg8K+ZkPi2E4jDa 4xhGjD4AYfYubcE/D20IsUTcM+NhEeYEjXqXLj49uo1fByF15LqlqdlRZezmHdnQ5zwbrTkK83NVSf gAeyhK6DzPP9JYz/9qdOkDhuhGnMh4A== X-KPN-MID: 33|go1j6jon/b8ALReFcDXyIwcI82PBXD+LVq+YHgaXerN6lBtGe0aerSgcYIEnnzX zvfm9EOvFi0YcwoJIPYRuhtJK8ukf4W3r6YdOu8OntEg= X-KPN-VerifiedSender: Yes X-CMASSUN: 33|tMBdNBO4lmvMseMCZ7hjjdvFegpdd3mkq50DeuklZ627vNTHiiBjDWudoLouIHP gZBVIxlWqmgQcqXIp36IMiQ== X-Originating-IP: 45.83.234.25 Received: from [192.168.178.31] (unknown [45.83.234.25]) by smtp.xs4all.nl (Halon) with ESMTPSA id 72b6e7e5-52b3-11ee-ad2d-005056998788; Thu, 14 Sep 2023 06:02:02 +0200 (CEST) Message-ID: Date: Thu, 14 Sep 2023 06:04:28 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.11.0 Subject: Re: JSON Path and GIN Questions To: "David E. Wheeler" Cc: Erik Wienhold , pgsql-hackers@lists.postgresql.org References: <15DD78A5-B5C4-4332-ACFE-55723259C07F@justatheory.com> <133696180.303713.1694566807910@office.mailbox.org> <640942d7-c996-0562-62c9-d69a4c1f9b1e@xs4all.nl> Content-Language: en-US From: Erik Rijkers In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk 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." >> >> That sentence is missing from the documentation. > > Where did that come from? Why wouldn’t JSON* functions use indexes? I see that the docs only mention operators; why would the corresponding functions behave the same? > > D 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. Compare these two statements: select count(id) from movies where movie @? '$ ? (@.year == 2023)' Time: 1.259 ms (index used) select count(id) from movies where jsonb_path_match(movie, '$.year == 2023'); Time: 17.260 ms (no index used - unexpectedly slower) With these two indexes available: using gin (movie); using gin (movie jsonb_path_ops); (REL_15_STABLE; but it's the same in HEAD and the not-yet-committed SQL/JSON patches.) Erik Rijkers