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
