What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
Choose HNSW when query speed and recall matter more than index-build time and memory; choose IVFFlat when a lighter, quicker-building index suits your workload and you can train it on representative table data. Neither option is universally faster in a particular deployment: both are approximate, and the right choice depends on measured recall, latency, filtering, and available resources.
What differs between HNSW and IVFFlat?
pgvector uses exact nearest-neighbor search by default. HNSW and IVFFlat are approximate indexes: they can make queries faster, but may not return the same nearest results as exact search. The pgvector project describes HNSW as having better query performance in the speed-recall tradeoff, with slower builds and greater memory use than IVFFlat. IVFFlat generally builds faster and uses less memory, but its query-performance tradeoff is lower. These are project-level comparisons, not a promise for every dataset or server. See the pgvector README.
As an Amazon Associate I earn from qualifying purchases.
| Decision factor | HNSW | IVFFlat |
|---|---|---|
| Query speed and recall | Project documentation describes a better speed-recall tradeoff. | Project documentation describes a lower speed-recall tradeoff. |
| Build time and memory | Slower to build and uses more memory. | Faster to build and uses less memory. |
| Data needed at index creation | No training step; can be created before data is loaded. | Needs trained lists based on table data; create it after loading data. |
| Primary controls | m, ef_construction, and query-time ef_search. |
lists and query-time probes. |
For a production decision, benchmark both with your data and query patterns rather than treating the qualitative comparison as a universal result.
Do these 3 things before closing this tab:
1Fix the driver behind crashes, sound loss and screen glitches2Clear out junk files and repair common Windows errors3Scan for outdated or missing drivers - takes under a minuteWhen should you choose HNSW?
Start with HNSW if query performance is the priority and your system can accommodate greater index memory and slower creation. HNSW builds a multilayer graph. It does not require IVFFlat’s data-based training step, so you can create the index before loading rows.
#1 Best Overall
HNSW settings
mcontrols the maximum number of connections per layer; its documented default is 16.ef_constructioncontrols the candidate list used during index construction; the documented default is 64. Raising it can improve recall, but increases build time and slows inserts.ef_searchcontrols the candidate list considered at query time; the documented default is 40. Raising it can improve recall while making queries slower.
The pgvector README advises keeping the defaults unless recall is too low. HNSW builds faster when its graph fits in maintenance_work_mem, but do not raise that setting so far that it exhausts server memory.
Create an HNSW index
CREATE INDEX ON items USING hnsw (embedding vector_cosine_ops);
This example uses cosine distance. The operator class must match the distance operator used in the query; consult the README for the supported operators, vector types, dimensional limits, and requirements for your installed pgvector version.
Rank #2
When should you choose IVFFlat?
Choose IVFFlat when lower memory use and quicker index creation are useful and you can build after representative data is present. IVFFlat groups vectors into lists and searches a subset of those lists near the query vector. Because the lists are trained from table data, creating the index before the table has data is a poor fit.
PC Slower Than It Used to Be?
A free scan shows the junk files, broken settings and background clutter dragging Windows down - then fixes them in one click.Free scan · Windows 10 & 11Crashes, No Sound, or Screen Glitches?
Random freezes, missing sound and display glitches usually trace back to one bad driver. Find and replace yours safely.Free scan · under a minuteStarting values for lists and probes
The README gives these as starting heuristics, not measured performance guarantees:
Rank #3
- For up to 1 million rows, start with
lists = rows / 1000. - Above 1 million rows, start with
lists = sqrt(rows). - Start with
probesaroundsqrt(lists).
Increasing probes searches more lists and can improve recall at a query-speed cost. If probes equals the number of lists, the search is exact and the planner will not use the IVFFlat index.
Create an IVFFlat index
CREATE INDEX ON items USING ivfflat (embedding vector_cosine_ops)
WITH (lists = 100);
Here, 100 is an example value, not a recommendation for every table. Choose the list count for your row count, then test it and the probe count against the workload.
How do filters affect index choice?
With approximate indexes, filtering happens after the index scan. A selective condition can therefore leave fewer rows than the requested result limit: the scan may not have visited enough qualifying vectors.
Recommended Free Tools
Starting with pgvector 0.8.0, iterative index scans can keep scanning until enough rows are found or a configured limit is reached. Strict ordering preserves exact distance order; relaxed ordering can improve recall while allowing slight deviations in distance order. Check the installed extension version before relying on these options.
- For a small number of distinct filter values, consider a partial index.
- For many filter values, consider partitioning.
- In a multitenant application, a shared approximate index can let one tenant’s vectors affect another tenant’s recall and speed. The pgvector documentation suggests list partitioning or separate tables for tenant isolation.
How should you benchmark and validate the choice?
- Measure exact results as a baseline. The pgvector README demonstrates disabling index scans within a transaction to compare approximate results with exact search. Use the same query and representative data for both.
- Compare recall and query speed. Test the actual distance operator, requested result count, filters, and workload mix. Adjust HNSW
ef_searchor IVFFlatprobesand observe the recall-versus-speed tradeoff. - Inspect query execution. Run
EXPLAIN (ANALYZE, BUFFERS)to see how the query behaves and what resources it uses. - Track index creation. Monitor progress with
pg_stat_progress_create_index, particularly when comparing build behavior.
The pgvector README does not establish a universal latency or recall benchmark, so results from one deployment should not be presented as a general ranking.
Check version and operator compatibility
The pgvector README was accessed on October 4, 2026, and its search result showed a v0.8.6 release reference. The README also identifies iterative scans as a feature introduced in v0.8.0. Confirm the extension version actually deployed before using version-sensitive settings or examples. Confirm that the index operator class and query distance operator match, and verify supported types and dimension limits in the current README.
Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.




