pg.ddx.io  pgvector/pgvector GitHub issues and pull requests  
help / color / mirror / Atom feed
[pgvector/pgvector] issue #560: 【ef_search】set hnsw.ef_search = 1001 failed
5+ messages / 4 participants
[nested] [flat]

* [pgvector/pgvector] issue #560: 【ef_search】set hnsw.ef_search = 1001 failed
@ 2024-05-17 07:38 "frg01 (@frg01)" <noreply+frg01@github.com>
  0 siblings, 0 replies; 5+ messages in thread

From: frg01 (@frg01) @ 2024-05-17 07:38 UTC (permalink / raw)
  To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>

Why is the boundary value of this parameter only 1,000, and there are tens of thousands of data in my table, but only 1,000 entries can be returned through the index? I don't think it makes sense

```
1. 
CREATE TABLE items_update4 (id bigserial ,embedding vector(3));

2. 
CREATE OR REPLACE FUNCTION public.add_vector_data(
 tb_name varchar,
    row_cnt integer,
 beg_id integer,
    vector_dimen integer, 
 vector_v_mul integer 
 )
    RETURNS void
    LANGUAGE 'plpgsql'

    COST 100
    VOLATILE 
AS $BODY$
declare
v_row_idx integer := 0;
embedding varchar := '';
v_strSql varchar := '';
begin         
  while v_row_idx < row_cnt loop  
 embedding := '''[' || array_to_string(ARRAY(SELECT random() * vector_v_mul FROM generate_series(1, vector_dimen)), ',') || ']''';
 v_strSql := 'insert into '||tb_name||'(id,embedding)values('||beg_id+v_row_idx||','||embedding||') ;';
 EXECUTE v_strSql; 
 v_row_idx = v_row_idx+1;
 if v_row_idx%1000=0 then
     raise notice'row_cnt: %',v_row_idx;
 end if; 
 
  end loop; 
end
$BODY$;

3.
SELECT COUNT(*)
FROM (
    SELECT * 
    FROM items_update4 
    ORDER BY embedding <-> '[1,2,3]' 
    LIMIT 10000
) AS subquery;

4. 
create index items_update4_spann_1 on items_update4 using hnsw (embedding vector_l2_ops);

5.
SELECT COUNT(*)
FROM (
    SELECT * 
    FROM items_update4 
    ORDER BY embedding <-> '[1,2,3]' 
    LIMIT 10000
) AS subquery;
```




No index can return any quantity, and creating an index can only return the number specified by the ef_search.
If you know, please tell me why




^ permalink  raw  [nested|flat] 5+ messages in thread

* Re: [pgvector/pgvector] issue #560: 【ef_search】set hnsw.ef_search = 1001 failed
@ 2024-05-17 11:32 ` "jkatz (@jkatz)" <noreply+jkatz@github.com>
  3 siblings, 0 replies; 5+ messages in thread

From: jkatz (@jkatz) @ 2024-05-17 11:32 UTC (permalink / raw)
  To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>

@frg01 What is your use case where you're trying to return more than 1000 entries in a single query?

^ permalink  raw  [nested|flat] 5+ messages in thread

* Re: [pgvector/pgvector] issue #560: 【ef_search】set hnsw.ef_search = 1001 failed
@ 2024-05-20 16:18 ` "ankane (@ankane)" <noreply+ankane@github.com>
  3 siblings, 0 replies; 5+ messages in thread

From: ankane (@ankane) @ 2024-05-20 16:18 UTC (permalink / raw)
  To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>

Hi @frg01, `hnsw.ef_search` is limited to 1,000 to limit memory usage. IVFFlat is recommended if you need more than 500 results ([docs](https://github.com/pgvector/pgvector?tab=readme-ov-file#why-are-there-less-results-for-a-query-after...)).

^ permalink  raw  [nested|flat] 5+ messages in thread

* Re: [pgvector/pgvector] issue #560: 【ef_search】set hnsw.ef_search = 1001 failed
@ 2024-05-20 16:18 ` "ankane (@ankane)" <noreply+ankane@github.com>
  3 siblings, 0 replies; 5+ messages in thread

From: ankane (@ankane) @ 2024-05-20 16:18 UTC (permalink / raw)
  To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>

@ankane closed this.

^ permalink  raw  [nested|flat] 5+ messages in thread

* Re: [pgvector/pgvector] issue #560: 【ef_search】set hnsw.ef_search = 1001 failed
@ 2026-02-11 01:01 ` "psrth (@psrth)" <noreply+psrth@github.com>
  3 siblings, 0 replies; 5+ messages in thread

From: psrth (@psrth) @ 2026-02-11 01:01 UTC (permalink / raw)
  To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>

i think this might have updated since. any guidance on limits and usage now?

^ permalink  raw  [nested|flat] 5+ messages in thread


end of thread, other threads:[~2026-02-11 01:01 UTC | newest]

Thread overview: 5+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2024-05-17 07:38 [pgvector/pgvector] issue #560: 【ef_search】set hnsw.ef_search = 1001 failed "frg01 (@frg01)" <noreply+frg01@github.com>
2024-05-17 11:32 ` "jkatz (@jkatz)" <noreply+jkatz@github.com>
2024-05-20 16:18 ` "ankane (@ankane)" <noreply+ankane@github.com>
2024-05-20 16:18 ` "ankane (@ankane)" <noreply+ankane@github.com>
2026-02-11 01:01 ` "psrth (@psrth)" <noreply+psrth@github.com>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox