Questions tagged [gist-index]

In computing, GiST or Generalized Search Tree, is a data structure and API that can be used to build a variety of disk-based search trees.

In computing, GiST or Generalized Search Tree, is a data structure and API that can be used to build a variety of disk-based search trees. GiST is a generalization of the B+ tree, providing a concurrent and recoverable height-balanced search tree infrastructure without making any assumptions about the type of data being stored, or the queries being serviced. GiST can be used to easily implement a range of well-known indexes, including B+ trees, R-trees, hB-trees, RD-trees, and many others; it also allows for easy development of specialized indexes for new data types. It cannot be used directly to implement non-height-balanced trees such as quad trees or prefix trees (tries), though like prefix trees it does support compression, including lossy compression. GiST can be used for any data type that can be naturally ordered into a hierarchy of supersets. Not only is it extensible in terms of data type support and tree layout, it allows the extension writer to support any query predicates that they choose. The most widely used GiST implementation is in the PostgreSQL relational database; it was also implemented in the Informix Universal Server, and as a standalone library, libgist.

GiST is an example of software extensibility in the context of database systems: it allows the easy evolution of a database system to support new tree-based indexes. It achieves this by factoring out its core system infrastructure from a narrow API that is sufficient to capture the application-specific aspects of a wide variety of index designs. The GiST infrastructure code manages the layout of the index pages on disk, the algorithms for searching indexes and deleting from indexes, and complex transactional details such as page-level locking for high concurrency and write-ahead logging for crash recovery. This allows authors of new tree-based indexes to focus on implementing the novel features of the new index type — for example, the way in which subsets of the data should be described for search — without becoming experts in database system internals.

Although originally designed for answering Boolean selection queries, GiST can also support nearest-neighbor search, and various forms of statistical approximation over large data sets.

The PostgreSQL GiST implementation includes support for variable length keys, composite keys, concurrency control and recovery; these features are inherited by all GiST extensions. There are several contributed modules developed using GiST and distributed with PostgreSQL. For example:

  • rtree_gist, btree_gist - GiST implementation of R-Tree and B-Tree
  • intarray - index support for one-dimensional array of int4's
  • tsearch2 - a searchable (full text) data type with indexed access
  • ltree - data types, indexed access methods and queries for data organized as a tree-like structures
  • hstore - a storage for (key,value) data
  • cube - data type, representing multidimensional cubes

The PostgreSQL GiST implementation provides the indexing support for the PostGIS (geographic information system) and the BioPostgres bioinformatics system.

Wikipedia: http://en.wikipedia.org/wiki/GiST

25 questions
39
votes
1 answer

PostgreSQL: GIN or GiST indexes?

From what information I could find, they both solve the same problems - more esoteric operations like array containment and intersection (&&, @>, <@, etc). However I would be interested in advice about when to use one or the other (or neither…
Grey Panther
  • 12,870
  • 6
  • 46
  • 64
17
votes
4 answers

What's the difference between B-Tree and GiST index methods (in PostgreSQL)?

I have been working on optimizing my Postgres databases recently, and traditionally, I've only ever use B-Tree indexes. However, I saw that GiST indexes suport non-unique, multicolumn indexes, in the Postgres 8.3 documentation. I couldn't, however,…
Ash
  • 24,276
  • 34
  • 107
  • 152
14
votes
2 answers

How to use uuid with postgresql gist index type?

I can't use directly uuid with gist index CREATE INDEX idx_leaderboads_values_gist ON leaderboard_entry USING gist (id_leaderboard , value); And I got this error: ERROR: data type uuid has no default operator class for access method …
xjodoin
  • 519
  • 5
  • 15
10
votes
1 answer

Postgres hstore: GIN vs GiST index performance

I have to decide whether to use GIN or GiST indexing for an hstore column. The Postgres docs state: GIN index lookups are about three times faster than GiST GIN indexes take about three times longer to build than GiST GIN indexes are about ten…
migu
  • 4,236
  • 5
  • 39
  • 60
9
votes
4 answers

PostgreSQL index not used for query on IP ranges

I'm using PostgreSQL 9.2 and have a table of IP ranges. Here's the SQL: CREATE TABLE ips ( id serial NOT NULL, begin_ip_num bigint, end_ip_num bigint, country_name character varying(255), CONSTRAINT ips_pkey PRIMARY KEY (id ) ) I've added…
Zain Zafar
  • 507
  • 2
  • 5
  • 19
7
votes
1 answer

PostgreSQL daterange not using index correctly

I have a simple table which has a user_birthday field with a type of date (which can be NULL value) CREATE TABLE users ( user_id bigserial NOT NULL, user_email text NOT NULL, user_password text, user_first_name text NOT NULL, …
Shahar Hadas
  • 2,641
  • 1
  • 27
  • 29
4
votes
0 answers

Postgres cube type distance vector index slower than seq scan

With a 128 dimension column and a distance query as below: CREATE TABLE testes (id serial, name text, face cube); CREATE INDEX testes_face_idx ON testes USING gist(face gist_cube_ops); explain analyse select name from testes order by face <->…
Kobus
  • 111
  • 2
4
votes
1 answer

PostgreSQL "IS [NOT] DISTINCT FROM" operator

Let's suppose a table: CREATE TABLE foo ( id serial primary key , range int4range NOT NULL , barid integer references bar(id) , baz whatever... NOT NULL , EXCLUDE USING gist (range WITH &&, barid WITH =) ); The exclusion constraint is…
murison
  • 3,640
  • 2
  • 23
  • 36
4
votes
2 answers

how can I detect gin and gist

how can I detect GIN and GiST indexes in postgresql? I am looking for if an database of postgres use fulltext. I think that a table use GIN o GiST then is using fulltext. I accept that GIN or GiST indexes does not necessarily mean that they are used…
3
votes
1 answer

PostgreSQL exclusion constraints in a bitemporal setting?

I am currently working with a bitemporal application, which stores data entries using 4 timestamps: Valid_from, Valid_to Registration_from, Registration_to The first two state when the given entry is valid_from and valid_to, and the other two are…
kafka
  • 573
  • 1
  • 11
  • 28
2
votes
1 answer

Is the relationship between index tuple in GiST index and user table row many to one or one to one?

In a regular b-tree index, the leaf node contains a key and a pointer to the heap tuple (user table row), which signifies that in b-tree, the relationship between index tuple and user table row is one-to-one. Just like in a b-tree, a GiST leaf node…
JessePinkman
  • 613
  • 8
  • 15
2
votes
1 answer

How to check if an unbounded range is NULL on the right in PostgreSQL 9.3 - ensuring GIST indexes are used

I'm using range datatypes in PG 9.3 (with btree_gist enabled, though I don't think it matters). I have GIST indexes that include these range columns. Some are int8range and some are tsrange. I want to query with a WHERE expression essentially saying…
jennykwan
  • 2,631
  • 1
  • 22
  • 33
1
vote
1 answer

Cannot use siglen parameter while creating index gist_trgm_ops in PostgreSQL 11.19 (Azure flexible DB)

When trying to create index on remote Azure server (PostgreSQL 11.19 on x86_64-pc-linux-gnu, compiled by gcc (Ubuntu 7.5.0-3ubuntu1~18.04) 7.5.0, 64-bit) create index test on "Table" using gist("Name" gist_trgm_ops(siglen=256)); with custom siglen…
1
vote
1 answer

Composite multicolumn index for geopoint range and numeric range query

I am building an app where the server needs to select rows based on some criteria/filters. One of them is the location of the user and the radius at which the user want's to see posts and other filters such date range and filter for a value of…
Najib
  • 199
  • 1
  • 8
1
vote
0 answers

Is it possible to call function in exclude contrains to return only specific column

I'm trying to implement exclude constraint and I have written the function which returns more than one separate parameters (types: character varying). What I want is to call this function twice, but choose different columns, something like this: ...…
alterego
  • 322
  • 1
  • 3
  • 11
1
2