This directory contains an implementation of GiST indexing for Postgres.
GiST is stands for Generalized Search Tree. It was introduced in seminal paper
"Generalized Search Trees for Database Systems", 1995,Joseph M. Hellerstein,
Jeffrey F. Naughton,Avi Pfeffer (http://www.sai.msu.su/~megera/postgres/gist/papers/gist.ps) and implemented by J. Hellerstein and P.Aoki in early version of
PostgreSQL ( more details is available from The GiST Indexing Project at
Berkeley at http://gist.cs.berkeley.edu/). As an "university" project it had a
limited number of features and was in rare use.
Current implementation of GiST supports:
* Variable length keys
* Composite keys (multi-key)
* provides NULL-safe interface to GiST core
* Concurrency
* Recovery support via WAL logging
Concurrence algoritms implemented in PostgreSQL were developed following paper
"Access Methods for Next-Generation Database Systems" by Marcel Kornaker (http://www.sai.msu.su/~megera/postgres/gist/papers/concurrency/access-methods-for-next-generation.pdf.gz).
Original algorithms were modified by following reasons:
* They should be adapted to PostgreSQL conventions. For example, SEARCH
algorithm was considerably changed, because in PostgreSQL function search
should return one tuple (next), not all tuples at once. Also, it should
release page locks between calls.
* since we added support of variable length keys, it's not possible to guarantee
enough free space for all keys on pages after splitting. User defined function
picksplit doesn't have information about size of tuples (each tuple may
contain several keys as in multicolumn index while picksplit could work with
only one key ) and pages.
* We modified original INSERT algorithm for perfomance reason. In particularly,
it's single-pass algorithm.
* Since the paper were theoretical, some details were omited and we have to find
out ourself how to solve some specific problems.
Because of above reasons, we have to revised interaction of GiST core and
PostgreSQL WAL system. Moreover, we encountered (and solved) a problem of
uncompleted insertions when recovering after crash, which was not touched in
the paper.
SEARCH ALGORITHM
Function gettuple finds tuple, which satisfy search predicate. It store their
state and returns next tuple under subsequent calls. Stack contains page,
its LSN and LSN of parent page and currentposition is saved between calls.