Stay organized with collections
Save and categorize content based on your preferences.
This document shows you how to tune your indexes to achieve faster query performance and better recall.
Analyze your queries
Use the EXPLAIN ANALYZE command to analyze your query insights as shown in the following example SQL query.
EXPLAINANALYZESELECTresult-columnFROMmy-tableORDERBYEMBEDDING_COLUMN<->embedding('text-embedding-005','What is a database?')::vectorLIMIT1;
The example response QUERY PLAN includes information such as the time taken, the number of rows scanned or returned, and the resources used.
Limit (cost=0.42..15.27 rows=1 width=32) (actual time=0.106..0.132 rows=1 loops=1)
-> Index Scan using my-scann-index on my-table (cost=0.42..858027.93 rows=100000 width=32) (actual time=0.105..0.129 rows=1 loops=1)
Order By: (embedding_column <-> embedding('text-embedding-005', 'What is a database?')::vector(768))
Limit value: 1
Planning Time: 0.354 ms
Execution Time: 0.141 ms
View vector index metrics
You can use the vector index metrics to review performance of your vector index,
identify areas for improvement, and tune your index based on the metrics, if
needed.
To view all vector index metrics, run the following SQL query, which uses the
pg_stat_ann_indexes view:
SELECT*FROMpg_stat_ann_indexes;
For more information about the complete list of metrics, see Vector index
metrics.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-03-25 UTC."],[[["This document guides users on tuning indexes for enhanced query speed and improved recall."],["Utilize the `EXPLAIN ANALYZE` command to gain insights into query performance, including time taken, rows scanned, and resource consumption."],["Vector index metrics, accessible via the `pg_stat_ann_indexes` view, allow for performance review and index tuning."],["ScaNN, IVF, IVFFlat, and HNSW are key components related to the indexing strategy discussed."]]],[]]