Skip to content

Commit

Permalink
jsonb_ops and array_ops opclasses (cockroachdb#15747)
Browse files Browse the repository at this point in the history
  • Loading branch information
taroface authored Dec 14, 2022
1 parent 87f1f23 commit d68daed
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 20 deletions.
22 changes: 14 additions & 8 deletions v22.2/inverted-indexes.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,17 +61,23 @@ This lets you search based on subcomponents.

You can use GIN indexes to improve the performance of queries using `JSONB` or `ARRAY` columns. You can create them:

- - Using the PostgreSQL-compatible syntax [`CREATE INDEX ... USING GIN`](create-index.html):
- Using the PostgreSQL-compatible syntax [`CREATE INDEX ... USING GIN`](create-index.html):

~~~ sql
CREATE INDEX {optional name} ON {table} USING GIN ({column});
~~~
~~~ sql
CREATE INDEX {optional name} ON {table} USING GIN ({column});
~~~

You can also specify the `jsonb_ops` or `array_ops` opclass (for `JSONB` and `ARRAY` columns, respectively) using the syntax:

~~~ sql
CREATE INDEX {optional name} ON {table} USING GIN ({column} {opclass});
~~~

- While creating the table, using the syntax [`CREATE INVERTED INDEX`](create-table.html#create-a-table-with-secondary-and-gin-indexes):
- While creating the table, using the syntax [`CREATE INVERTED INDEX`](create-table.html#create-a-table-with-secondary-and-gin-indexes):

~~~ sql
CREATE INVERTED INDEX {optional name} ON {table} ({column});
~~~
~~~ sql
CREATE INVERTED INDEX {optional name} ON {table} ({column});
~~~

### Selection

Expand Down
24 changes: 12 additions & 12 deletions v22.2/trigram-indexes.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,23 +77,23 @@ To create a trigram index, use the [`CREATE INDEX`](create-index.html) syntax th

- Using the PostgreSQL-compatible syntax:

~~~ sql
CREATE INDEX {optional name} ON {table} USING GIN({column} gin_trgm_ops);
~~~
~~~ sql
CREATE INDEX {optional name} ON {table} USING GIN({column} gin_trgm_ops);
~~~

~~~ sql
CREATE INDEX {optional name} ON {table} USING GIST({column} gist_trgm_ops);
~~~
~~~ sql
CREATE INDEX {optional name} ON {table} USING GIST({column} gist_trgm_ops);
~~~

{{site.data.alerts.callout_info}}
GIN and GiST indexes are implemented identically on CockroachDB. `GIN` and `GIST` are therefore synonymous when defining a trigram index.
{{site.data.alerts.end}}
{{site.data.alerts.callout_info}}
GIN and GiST indexes are implemented identically on CockroachDB. `GIN` and `GIST` are therefore synonymous when defining a trigram index.
{{site.data.alerts.end}}

- Using `CREATE INVERTED INDEX`:

~~~ sql
CREATE INVERTED INDEX {optional name} ON {table} ({column} {opclass});
~~~
~~~ sql
CREATE INVERTED INDEX {optional name} ON {table} ({column} {opclass});
~~~

### Comparisons

Expand Down

0 comments on commit d68daed

Please sign in to comment.