pg-vector not using hnsw indexes
Problem
Help me!!! I created the index using hnsw, but I can't use the index for even the simplest query My system info: [code block] My Table Structure: [code block] My query sql: [code block] Analyse result: [code block] From explain result, I can see that the index is not being used. Any idea what I am doing wrong @ankane
Unverified for your environment
Select your OS to check compatibility.
1 Fix
Solution: pg-vector not using hnsw indexes
> No, it means the planner will use (and show) a different plan when there's more data.不,这意味着当有更多数据时,计划器将使用(并显示)不同的计划。 Hi~ I have now increased the amount of data to 8000 entries and the index is now working properly. Thanks again for your answer! ```sql -- analyse result Limit (cost=108.60..108.72 rows=2 width=16) (actual time=4.346..4.375 rows=2 loops=1) -> Index Scan using faces_tsv_conte
Trust Score
2 verifications
- 1
> No, it means the planner will use (and show) a different plan when there's mor
> No, it means the planner will use (and show) a different plan when there's more data.不,这意味着当有更多数据时,计划器将使用(并显示)不同的计划。
- 2
Hi~ I have now increased the amount of data to 8000 entries and the index is now
Hi~ I have now increased the amount of data to 8000 entries and the index is now working properly. Thanks again for your answer!
- 3
Step 3
-- analyse result Limit (cost=108.60..108.72 rows=2 width=16) (actual time=4.346..4.375 rows=2 loops=1) -> Index Scan using faces_tsv_content_hnsw_idx on faces (cost=108.60..628.14 rows=8923 width=16) (actual time=4.344..4.372 rows=2 loops=1) Order By: (tsv_content <=> '[-0.121626005... ,0.015510366]'::vector)" Planning Time: 0.357 ms Execution Time: 4.467 ms
Validation
Resolved in pgvector/pgvector GitHub issue #501. Community reactions: 1 upvotes.
Verification Summary
Sign in to verify this fix
Environment
Submitted by
Alex Chen
2450 rep