4 Work with Indexes for JSON Data in TimesTen
JSON type column using function-based indexes. The
following restrictions apply:
-
Each index can have one or more fields from only one
JSONtype column. No such restriction exists for nonJSONtype columns. -
The index cannot be used as primary key.
Function-based indexing is appropriate for queries that target particular functions, which in this context means particular SQL/JSON path expressions. This indexing is not very helpful for ad hoc structural queries. Define a function-based index if you know that you will often query a particular path expression.
-
For indexes that target a single scalar JSON value, use function-based indexes for the
JSON_VALUEfunction.An index created using
JSON_VALUEwith theERROR ON ERRORclause can be used for a query involving theJSON_TABLEfunction. This index acts as a constraint on the indexed path to ensure that only one (nonnull) scalar JSON value is projected for each item in the JSON data. -
For indexes that target scalar values as elements of a JSON array, use multivalue function-based indexes for the
JSON_EXISTSfunction.Although, a multivalue index—an index created using
JSON_TABLE—can index a single scalar value, if you expect a path expression that target such value then it is more performance efficient to use aJSON_VALUEindex.
Path expressions that contain filter expressions can be used in queries that pick up a function-based index, but a path expression that you use to define a function-based index cannot contain filter expressions.
TimesTen creates a materialized view and an index on the materialized view
for each JSON index. The materialized view can have multiple function-based indexes for
JSON_VALUE functions, but it can only have one function-based index
for JSON_TABLE functions.
Note:
The JSON_QUERY function or JSON_EQUAL
or JSON_EXISTS conditions are not supported for function-based
index creation.