Re: Patch: Improve Boolean Predicate JSON Path Docs

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "David E(dot) Wheeler" <david(at)justatheory(dot)com>
Cc: Erik Wienhold <ewie(at)ewie(dot)name>, pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: Patch: Improve Boolean Predicate JSON Path Docs
Date: 2024-01-20 16:45:12
Message-ID: 3004346.1705769112@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

"David E. Wheeler" <david(at)justatheory(dot)com> writes:
> While you’re in there, Tom, would it make sense to fold in something like [this patch][1] I posted last month to clarify which JSONPath comparison operators can take advantage of a index?

> --- a/doc/src/sgml/json.sgml
> +++ b/doc/src/sgml/json.sgml
> @@ -513,7 +513,7 @@ SELECT jdoc->'guid', jdoc->'name' FROM api WHERE jdoc @@ '$.tags[*] == "qui"';
> </programlisting>
> For these operators, a GIN index extracts clauses of the form
> <literal><replaceable>accessors_chain</replaceable>
> - = <replaceable>constant</replaceable></literal> out of
> + == <replaceable>constant</replaceable></literal> out of
> the <type>jsonpath</type> pattern, and does the index search based on
> the keys and values mentioned in these clauses. The accessors chain
> may include <literal>.<replaceable>key</replaceable></literal>,

Right, clearly a typo.

> @@ -522,6 +522,9 @@ SELECT jdoc->'guid', jdoc->'name' FROM api WHERE jdoc @@ '$.tags[*] == "qui"';
> The <literal>jsonb_ops</literal> operator class also
> supports <literal>.*</literal> and <literal>.**</literal> accessors,
> but the <literal>jsonb_path_ops</literal> operator class does not.
> + Only the <literal>==</literal> and <literal>!=</literal> <link
> + linkend="functions-sqljson-path-operators">SQL/JSON Path Operators</link>
> + can use the index.
> </para>

You sure about that? It would surprise me if we could effectively use
a not-equal condition with an index. If it is only == that works,
then the preceding statement seems sufficient.

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2024-01-20 17:34:19 Re: Patch: Improve Boolean Predicate JSON Path Docs
Previous Message Tom Lane 2024-01-20 16:12:11 Re: PG12 change to DO UPDATE SET column references