parray_gin
parray_gin : GIN index operator class and partial-match operators for text arrays
Overview
| ID | Extension | Package | Version | Category | License | Language |
|---|---|---|---|---|---|---|
| 4860 | parray_gin
|
parray_gin
|
1.4.0 |
FUNC
|
PostgreSQL
|
C
|
| Attribute | Has Binary | Has Library | Need Load | Has DDL | Relocatable | Trusted |
|---|---|---|---|---|---|---|
--s-d-r
|
No
|
Yes
|
No
|
Yes
|
yes
|
no
|
| Relationships | |
|---|---|
| See Also | intarray
btree_gin
btree_gist
pg_trgm
smlar
aggs_for_arrays
aggs_for_vecs
arraymath
|
PGXN dist name and PostgreSQL extension name are both parray_gin; Pigsty packages are built for PG 14-18.
Packages
| Type | Repo | Version | PG Major Compatibility | Package Pattern | Dependencies |
|---|---|---|---|---|---|
| EXT | PIGSTY
|
1.4.0 |
18
17
16
15
14
|
parray_gin |
- |
| RPM | PIGSTY
|
1.4.0 |
18
17
16
15
14
|
parray_gin_$v |
- |
| DEB | PIGSTY
|
1.4.0 |
18
17
16
15
14
|
postgresql-$v-parray-gin |
- |
| Linux / PG | PG18 | PG17 | PG16 | PG15 | PG14 |
|---|---|---|---|---|---|
el8.x86_64
|
PIGSTY 1.4.0
|
PIGSTY 1.4.0
|
PIGSTY 1.4.0
|
PIGSTY 1.4.0
|
PIGSTY 1.4.0
|
el8.aarch64
|
PIGSTY 1.4.0
|
PIGSTY 1.4.0
|
PIGSTY 1.4.0
|
PIGSTY 1.4.0
|
PIGSTY 1.4.0
|
el9.x86_64
|
PIGSTY 1.4.0
|
PIGSTY 1.4.0
|
PIGSTY 1.4.0
|
PIGSTY 1.4.0
|
PIGSTY 1.4.0
|
el9.aarch64
|
PIGSTY 1.4.0
|
PIGSTY 1.4.0
|
PIGSTY 1.4.0
|
PIGSTY 1.4.0
|
PIGSTY 1.4.0
|
el10.x86_64
|
PIGSTY 1.4.0
|
PIGSTY 1.4.0
|
PIGSTY 1.4.0
|
PIGSTY 1.4.0
|
PIGSTY 1.4.0
|
el10.aarch64
|
PIGSTY 1.4.0
|
PIGSTY 1.4.0
|
PIGSTY 1.4.0
|
PIGSTY 1.4.0
|
PIGSTY 1.4.0
|
d12.x86_64
|
PIGSTY 1.4.0
|
PIGSTY 1.4.0
|
PIGSTY 1.4.0
|
PIGSTY 1.4.0
|
PIGSTY 1.4.0
|
d12.aarch64
|
PIGSTY 1.4.0
|
PIGSTY 1.4.0
|
PIGSTY 1.4.0
|
PIGSTY 1.4.0
|
PIGSTY 1.4.0
|
d13.x86_64
|
PIGSTY 1.4.0
|
PIGSTY 1.4.0
|
PIGSTY 1.4.0
|
PIGSTY 1.4.0
|
PIGSTY 1.4.0
|
d13.aarch64
|
PIGSTY 1.4.0
|
PIGSTY 1.4.0
|
PIGSTY 1.4.0
|
PIGSTY 1.4.0
|
PIGSTY 1.4.0
|
u22.x86_64
|
PIGSTY 1.4.0
|
PIGSTY 1.4.0
|
PIGSTY 1.4.0
|
PIGSTY 1.4.0
|
PIGSTY 1.4.0
|
u22.aarch64
|
PIGSTY 1.4.0
|
PIGSTY 1.4.0
|
PIGSTY 1.4.0
|
PIGSTY 1.4.0
|
PIGSTY 1.4.0
|
u24.x86_64
|
PIGSTY 1.4.0
|
PIGSTY 1.4.0
|
PIGSTY 1.4.0
|
PIGSTY 1.4.0
|
PIGSTY 1.4.0
|
u24.aarch64
|
PIGSTY 1.4.0
|
PIGSTY 1.4.0
|
PIGSTY 1.4.0
|
PIGSTY 1.4.0
|
PIGSTY 1.4.0
|
Source
pig build pkg parray_gin; # build rpm/debInstall
Make sure PGDG and PIGSTY repo available:
pig repo add pgsql -u # add both repo and update cacheInstall this extension with pig:
pig install parray_gin; # install via package name, for the active PG version
pig install parray_gin -v 18; # install for PG 18
pig install parray_gin -v 17; # install for PG 17
pig install parray_gin -v 16; # install for PG 16
pig install parray_gin -v 15; # install for PG 15
pig install parray_gin -v 14; # install for PG 14Create this extension with:
CREATE EXTENSION parray_gin;Usage
Syntax:
CREATE EXTENSION parray_gin; CREATE INDEX test_tags_idx ON test_table USING gin (val parray_gin_ops); SELECT * FROM test_table WHERE val @> ARRAY['must','contain']; SELECT * FROM test_table WHERE val @@> ARRAY['what%like%'];
parray_gin adds GIN indexing and operators for text[] arrays with both strict and partial matching. The upstream docs describe it as trigram-based array indexing built on pg_trgm’s trigram implementation.
Indexing Arrays
The extension provides the parray_gin_ops operator class for GIN indexes on text arrays:
CREATE TABLE test_table(id bigserial, val text[]);
CREATE INDEX test_tags_idx ON test_table USING gin (val parray_gin_ops);According to the reference docs, indexed values and queries are split into trigrams. Because the trigram index can return false positives, operator matches are rechecked after index lookup.
Operators
Strict Matching
@> (text[], text[]) -> bool
Returns true when the left-hand array contains all items from the right-hand array.
SELECT * FROM test_table WHERE val @> ARRAY['far'];<@ (text[], text[]) -> bool
Returns true when the left-hand array is contained by the right-hand array.
SELECT * FROM test_table WHERE val <@ ARRAY['galaxy','ago','vader'];Partial Matching
@@> (text[], text[]) -> bool
Returns true when the left-hand array contains all right-hand items using partial matching, for example 'foobar' ~~ 'foo%' or 'foobar' ~~ '%oo%'.
SELECT * FROM test_table WHERE val @@> ARRAY['%ar%'];<@@ (text[], text[]) -> bool
Returns true when the left-hand array is contained by the right-hand patterns using partial matching.
SELECT * FROM test_table WHERE val <@@ ARRAY['%ar%','vader'];Notes
The upstream docs say GIN can be used with @>, <@, @@>, and <@@. They also mention successful use on JSON arrays extracted from JSON text fields via the json_accessors extension.