Q15 PostgreSQL Domain 2 · 25–30% of exam Priority · Real Exam Choose 2

A pgvector query over 2 million rows is slow. Which TWO changes are appropriate?

  1. A Create an HNSW index on the embedding column (correct answer)
  2. B Ensure the query's distance operator matches the index's operator class (correct answer)
  3. C Raise work_mem to 8 GB
  4. D Drop the primary key
  5. E Convert the embedding column to text

Shortcut: HNSW gives high recall with fast lookups at scale. Crucially, the index is only used when the query operator matches the operator class it was built with — an index built for cosine distance is ignored by an L2 query, which silently falls back to a sequential scan.