Title: Quiz 4 — Indexing Deep Dive: HNSW vs IVF and Metadata Filtering
Course: AIINFRA 301: Production RAG & LLMOps — Observability and Evaluation > Section: Week 04 — Indexing Deep Dive: HNSW vs IVF and Metadata Filtering

Q: What is the approximate query complexity of HNSW search as the number of vectors n grows?
- O(n)
- O(log n)
- O(n\^2)
- O(1), constant regardless of n
A: O(log n)

Q: An IVFFlat index in pgvector can be created on an empty table with no data present, the same way an HNSW index can.
- True
- False
A: False

Q: Which pgvector setting controls query-time recall/latency trade-off for an HNSW index without requiring a rebuild?
- `m`
- `ef_construction`
- `hnsw.ef_search`
- `lists`
A: `hnsw.ef_search`

Q: What is the common sizing heuristic for choosing nlist (pgvector's lists) when building an IVF index over n vectors?
Feedback: Sample/expected answer: nlist ≈ sqrt(n)** (roughly the square root of the number of vectors)

Q: Raising m and ef_construction as high as possible always meaningfully improves recall, with no real downside besides a longer build.
- True
- False
A: False

Q: Under a highly selective metadata filter (e.g., excluding more than 90% of vectors), which index type generally degrades more severely toward brute-force-like behavior?
- IVF, because centroids become meaningless under filtering
- HNSW, because the graph can fragment when most candidates are excluded
- Both degrade identically
- Neither is affected by metadata filtering
A: HNSW, because the graph can fragment when most candidates are excluded

Q: In pgvector, what is the default value of probes for an IVFFlat query, and why does leaving it at that default typically hurt recall?
Feedback: Sample/expected answer: probes = 1** by default, which only searches the single closest partition/centroid, missing relevant vectors that landed in neighboring partitions — you must raise `probes` (e.g., toward `~sqrt(nlist)`) to recover recall.

Q: An unindexed pgvector column performing a sequential scan gives 100% recall, because it is an exact search rather than an approximate one.
- True
- False
A: True