liveBook · Manning

Index type

As explained in Just Use Postgres!

An index type is a classification of database indexes based on the access method and structure they use to support data retrieval.

An index type classifies an index by the access method and structure it uses to retrieve data. Choosing among types helps keep database queries responsive as applications and datasets grow. section 4.0 section 8.5

For vector embeddings, available index types include:

  • IVFFlat, or inverted file with flat compression. section 8.5
  • HNSW, or hierarchical navigable small world. section 8.5
  • StreamingDiskANN, provided through the pgvectorscale extension. section 8.5

Movie similarity search

Without a vector index, PostgreSQL performs a sequential scan of more than 4,000 movies, computes cosine distances for 1,024-dimensional embeddings, sorts the results, and returns the top three. This works for small datasets but becomes expensive as usage grows. section 8.5

How Just Use Postgres! covers it

How deep it goes
Defines index types by access method and structure, then names vector options without detailing their internal algorithms.
Examples
Uses a multiplayer game and a movie recommendation query that scans, sorts, and limits vector-search results.
What it assumes
Assumes familiarity with generated embeddings and similarity search before introducing specialized vector indexes.
What you can do after
Evaluate/understand how specialized indexes can replace costly full scans for vector similarity searches as datasets grow.
How it connects
Connects index types to query execution plans, similarity search, vector embeddings, and query performance.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Just Use Postgres!. The section links point to the parts of the book it draws on.