You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/current/v25.4/jsonpath.md
+19-1Lines changed: 19 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -11,6 +11,8 @@ docs_area: reference.sql
11
11
12
12
JSONPath expressions and functions are used to query and filter [`JSONB`]({% link {{ page.version.version }}/jsonb.md %}) data. A [JSONPath expression](#jsonpath-expression) is a string that identifies one or more elements in a JSON document, and is used as a [JSONPath function](#jsonpath-functions) argument.
13
13
14
+
{% include_cached new-in.html version="v25.4" %} [GIN indexes]({% link {{ page.version.version }}/inverted-indexes.md %}) on `JSONB` columns automatically accelerate [`jsonb_path_exists`](#jsonpath-functions) queries in certain [filter patterns](#index-accelerated-patterns). This can significantly improve query performance when filtering large datasets.
15
+
14
16
## JSONPath expression
15
17
16
18
A JSONPath expression consists of an optional [mode](#structural-error-handling) (`lax` or `strict`), followed by a scalar expression (such as `1 + 2`), a predicate expression (such as `1 != 2` or `exists($)`), or a path-based expression rooted at `$`. A path-based expression is composed of one or more [accessor](#accessor-operators) operators that are optionally interleaved with one or more [filter expressions](#filter-expressions) introduced by `?`. Expressions can optionally include scalar expressions, [predicate operators](#predicate-operators) for conditional logic, and a [method](#methods) applied to the current value. The path is evaluated left to right, and each stage refines or filters the result.
@@ -135,7 +137,7 @@ Use JSONPath functions to extract or evaluate target `JSONB` data according to a
|`jsonb_path_exists(jsonb, jsonpath)`| Returns true if any match is found. |`false`|
140
+
|`jsonb_path_exists(jsonb, jsonpath)`| Returns true if any match is found. Accelerated by GIN indexes for certain [filter patterns](#index-accelerated-patterns).|`false`|
139
141
|`jsonb_path_match(jsonb, jsonpath)`| Returns true if the path expression evaluates to true. Only useful with [predicate check expressions](#check-expressions), as it expects a single Boolean value. |`false`|
140
142
|`jsonb_path_query(jsonb, jsonpath)`| Returns all matches as a set of `JSONB` values. |`NULL`|
141
143
|`jsonb_path_query_array(jsonb, jsonpath)`| Returns all matches as a single `JSONB` array. |`[]`|
@@ -416,6 +418,22 @@ For example, the following JSONPath expression selects all elements in an `items
416
418
$.items[*] ? (@.price > 100).name;
417
419
~~~
418
420
421
+
<aname="index-accelerated-patterns"></a>
422
+
423
+
[GIN indexes]({% link {{ page.version.version }}/inverted-indexes.md %}) on `JSONB` columns automatically accelerate [`jsonb_path_exists`](#jsonpath-functions) when used in `WHERE` clause filters with the following patterns:
0 commit comments