A signature tree is the GiST structure PostgreSQL creates for indexing tsvector lexemes. Each entry summarizes a text document as a bit string. section 6.6.2
Signature construction follows three steps:
- Assign each lexeme a signature with one bit set to 1. section 6.6.2
- Combine the lexeme signatures with bitwise OR to represent a document. section 6.6.2
- Traverse the tree from root pages to leaf entries containing document signatures and table-row references. section 6.6.2
Create and inspect a GiST signature tree
CREATE INDEX idx_movie_lexemes_gist ON omdb.movies USING GIST (lexemes); EXPLAIN (analyze, costs off) SELECT id, name FROM omdb.movies WHERE lexemes @@ to_tsquery('historical & fight'); The plan reports an Index Scan using idx_movie_lexemes_gist, returning three rows.
Figure 6.2 A sample GiST index highlighting all the index entries visited during a search for documents containing the “histor” lexeme (00000001)
Follow the tree search for the “histor” lexeme from the root through visited index entries. section 6.6.2
