FG
💻 Software🤖 AI & LLMs

pg-vector not using hnsw indexes

Freshalmost 2 years ago
Mar 14, 20260 views
Confidence Score85%
85%

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

Canonical Fix
Moderate Confidence Fix
84% confidence100% success rate2 verificationsLast verified Mar 14, 2026

Solution: pg-vector not using hnsw indexes

Low Risk

> 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

84

Trust Score

2 verifications

100% success
  1. 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. 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. 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

Worked: 2
Last verified Mar 14, 2026

Sign in to verify this fix

Environment

Submitted by

AC

Alex Chen

2450 rep

Tags

pgvectorembeddingsvector-search