![[assets/str_idx_gist.png|256]]
- **Description**: "Generalized Search Tree". It's a height-balanced tree framework that allows for the implementation of arbitrary indexing schemes. Unlike B-Tree, keys in a GiST index can overlap, which is handled by a **Penalty function** during insertion.
- **The Framework Interface**: To implement a new type (using `CREATE OPERATOR CLASS`), you must provide:
- `consistent`: Can this page contain matches for the query?
- `union`: Combine multiple internal keys into one.
- `compress/decompress`: Optimize key storage on disk.
- `penalty`: How much would it 'cost' to insert this new key here?
- `picksplit`: How to divide a sibling page when it overflows.
- **Supported Operators**: Varies significantly (e.g., `&&`, `@>`, `<@`, `~=`).
- **Special Features**:
- **Nearest-Neighbor (k-NN)**: Supports ordered distance-based searches using the `<->` operator, highly optimized for PostGIS and 2D/3D points.
- **Multidimensional**: Excellent for spatial geometry, ranges, and hstore.
- **Metaphor**: A multi-layered, magical sieve. You throw a bunch of shapes at it, and it catches exactly the ones that "overlap" or are "nearby" your target. If the sieve gets too full, the `picksplit` logic ensures the chaos is divided into two new, slightly-less-chaotic sieves.