Optimize query latency and reduce pgvector compute
Unlock the complete study guide + 1,040 practice questions across 16 full exams.
Bundled into the existing Developing AI Cloud Solutions on Azure premium course — no separate purchase.
14-day money-back guarantee — no questions asked.
Included in this chapter:
- Three moments: the column, the index, the query
- Where a tuning value lives: transaction, session, server
- Choosing the access method: hnsw, ivfflat, or diskann
- Tuning hnsw: m, ef_construction, and ef_search
- Tuning ivfflat: lists at build, probes per query
- Shrinking the vector: precision, quantization, ceilings
- Reading the plan: Index Scan or Seq Scan
- Exam-pattern recognition
Choosing an approximate access method on Azure Database for PostgreSQL flexible server
| Decision axis | hnsw | ivfflat | diskann |
|---|---|---|---|
| Where it comes from | vector extension (pgvector) | vector extension (pgvector) | pg_diskann extension, documented as supported only on Azure Database for PostgreSQL flexible server |
| Build cost | Slower to build, uses more memory | Faster to build, uses less memory | Slower to build and more memory than ivfflat |
| Speed-recall tradeoff | Better than ivfflat | Lower than hnsw | Documented for high recall and low query latency at very large scale |
| Needs data before you build | No training step, so it can be created on an empty table | Yes: recall depends on building after representative rows are loaded | No training step, so it can be created on an empty table |
| Build-time options | m (16 by default), ef_construction (64 by default) | lists | max_neighbors (32 by default), l_value_ib, product_quantized (false by default) |
| Search-effort setting | hnsw.ef_search (40 by default) | ivfflat.probes (1 by default) | diskann.l_value_is (100 by default) |
| Indexable dimensions for a vector column | Up to 2,000 | Up to 2,000 | Up to 16,000 from v0.6, with product quantization enabled |
Decision tree
Cheat sheet
Unlock with Premium — includes all practice exams and the complete study guide.
Also tested in
References
- Optimize performance when using pgvector in Azure Database for PostgreSQL flexible server
- PostgreSQL: CREATE INDEX (access methods and operator classes)
- List of extensions and modules by name in Azure Database for PostgreSQL flexible server
- PostgreSQL: SET (SESSION and LOCAL scope)
- Server parameters in Azure Database for PostgreSQL flexible server
- List read-only server parameters
- List read-write dynamic server parameters
- List read-write static server parameters
- Enable and use DiskANN in Azure Database for PostgreSQL flexible server
- Vector search in Azure Database for PostgreSQL flexible server (pgvector basics)
- PostgreSQL: resource-consumption parameters (maintenance_work_mem, max_parallel_maintenance_workers)