Auf dieser Seite wird beschrieben, wie Sie Ihre Indexe optimieren, um eine schnellere Abfrageleistung und einen besseren Recall in AlloyDB Omni zu erzielen.
Abfragen analysieren
Verwenden Sie den Befehl EXPLAIN ANALYZE, um Ihre Abfragestatistiken zu analysieren, wie in der folgenden SQL-Beispielabfrage gezeigt.
EXPLAINANALYZESELECTresult-columnFROMmy-tableORDERBYEMBEDDING_COLUMN<->embedding('text-embedding-005','What is a database?')::vectorLIMIT1;
Die Beispielantwort QUERY PLAN enthält Informationen wie die benötigte Zeit, die Anzahl der gescannten oder zurückgegebenen Zeilen und die verwendeten Ressourcen.
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
Messwerte für Vektorindexe ansehen
Mithilfe der Messwerte für Vektorindexe können Sie die Leistung Ihres Vektorindex überprüfen, Bereiche für Verbesserungen identifizieren und den Index bei Bedarf anhand der Messwerte optimieren.
Wenn Sie alle Messwerte für Vektorindexe aufrufen möchten, führen Sie die folgende SQL-Abfrage aus, in der die Ansicht pg_stat_ann_indexes verwendet wird:
SELECT*FROMpg_stat_ann_indexes;
Weitere Informationen zur vollständigen Liste der Messwerte finden Sie unter Messwerte für Vektorindex.
[[["Leicht verständlich","easyToUnderstand","thumb-up"],["Mein Problem wurde gelöst","solvedMyProblem","thumb-up"],["Sonstiges","otherUp","thumb-up"]],[["Schwer verständlich","hardToUnderstand","thumb-down"],["Informationen oder Beispielcode falsch","incorrectInformationOrSampleCode","thumb-down"],["Benötigte Informationen/Beispiele nicht gefunden","missingTheInformationSamplesINeed","thumb-down"],["Problem mit der Übersetzung","translationIssue","thumb-down"],["Sonstiges","otherDown","thumb-down"]],["Zuletzt aktualisiert: 2025-09-03 (UTC)."],[[["\u003cp\u003eThis document provides guidance on tuning indexes to enhance query speed and recall.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003eEXPLAIN ANALYZE\u003c/code\u003e command can be used to analyze query performance, revealing details like execution time and resources used.\u003c/p\u003e\n"],["\u003cp\u003eVector index metrics, accessible via the \u003ccode\u003epg_stat_ann_indexes\u003c/code\u003e view, can be leveraged to review and improve the performance of vector indexes.\u003c/p\u003e\n"],["\u003cp\u003eScaNN IVF IVFFlat HNSW are used in relation to indexing and performance tuning.\u003c/p\u003e\n"]]],[],null,["Select a documentation version: 15.7.1keyboard_arrow_down\n\n- [Current (16.8.0)](/alloydb/omni/current/docs/ai/tune-indexes)\n- [16.8.0](/alloydb/omni/16.8.0/docs/ai/tune-indexes)\n- [16.3.0](/alloydb/omni/16.3.0/docs/ai/tune-indexes)\n- [15.12.0](/alloydb/omni/15.12.0/docs/ai/tune-indexes)\n- [15.7.1](/alloydb/omni/15.7.1/docs/ai/tune-indexes)\n- [15.7.0](/alloydb/omni/15.7.0/docs/ai/tune-indexes)\n\n\u003cbr /\u003e\n\nThis document describes how to tune your indexes to achieve faster query\nperformance and better recall in AlloyDB Omni. \nScaNN IVF IVFFlat HNSW\n\nAnalyze your queries\n\nUse the `EXPLAIN ANALYZE` command to analyze your query insights as shown in the following example SQL query. \n\n EXPLAIN ANALYZE SELECT result-column\n FROM my-table\n ORDER BY EMBEDDING_COLUMN \u003c-\u003e embedding('text-embedding-005', 'What is a database?')::vector\n LIMIT 1;\n\nThe example response `QUERY PLAN` includes information such as the time taken, the number of rows scanned or returned, and the resources used. \n\n Limit (cost=0.42..15.27 rows=1 width=32) (actual time=0.106..0.132 rows=1 loops=1)\n -\u003e 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)\n Order By: (embedding_column \u003c-\u003e embedding('text-embedding-005', 'What is a database?')::vector(768))\n Limit value: 1\n Planning Time: 0.354 ms\n Execution Time: 0.141 ms\n\nView vector index metrics\n\nYou can use the vector index metrics to review performance of your vector index,\nidentify areas for improvement, and tune your index based on the metrics, if\nneeded.\n\nTo view all vector index metrics, run the following SQL query, which uses the\n`pg_stat_ann_indexes` view: \n\n SELECT * FROM pg_stat_ann_indexes;\n\nFor more information about the complete list of metrics, see [Vector index\nmetrics](/alloydb/omni/15.7.1/docs/reference/vector-index-metrics).\n\nWhat's next\n\n- [An example embedding workflow](/alloydb/omni/15.7.1/docs/ai/example-embeddings)"]]