RefLib

Reference library for AI

Back

postgresql_16:9.6.23.3 Indexes

PostgreSQL 16 > Appendixes > Additional Supplied Modules and Extensions > ltree — hierarchical tree-like data type > Indexes

ltree supports several types of indexes that can speed up the indicated operators:

gist_ltree_ops GiST opclass approximates a set of path labels as a bitmap signature. Its optional integer parameter siglen determines the signature length in bytes. The default signature length is 8 bytes. The length must be a positive multiple of int alignment (4 bytes on most machines)) up to 2024. Longer signatures lead to a more precise search (scanning a smaller fraction of the index and fewer heap pages), at the cost of a larger index.

Example of creating such an index with the default signature length of 8 bytes:

`` CREATE INDEX path_gist_idx ON test USING GIST (path); ``

Example of creating such an index with a signature length of 100 bytes:

`` CREATE INDEX path_gist_idx ON test USING GIST (path gist_ltree_ops(siglen=100)); ``

gist__ltree_ops GiST opclass works similarly to gist_ltree_ops and also takes signature length as a parameter. The default value of siglen in gist__ltree_ops is 28 bytes.

Example of creating such an index with the default signature length of 28 bytes:

`` CREATE INDEX path_gist_idx ON test USING GIST (array_path); ``

Example of creating such an index with a signature length of 100 bytes:

`` CREATE INDEX path_gist_idx ON test USING GIST (array_path gist__ltree_ops(siglen=100)); ``

Note: This index type is lossy.

Back