From noreply+dpresonate@github.com Fri Nov 22 20:16:51 2024 Message-ID: From: "dpresonate (@dpresonate)" To: "pgvector/pgvector" Date: Fri, 22 Nov 2024 20:16:51 +0000 Subject: [pgvector/pgvector] issue #716: LIMIT clause is not Respected > 40 < 2575 List-Id: X-GitHub-Author-Id: 167116789 X-GitHub-Author-Login: dpresonate X-GitHub-Issue: 716 X-GitHub-Repo: pgvector/pgvector X-GitHub-State: closed X-GitHub-Type: issue X-GitHub-Url: https://github.com/pgvector/pgvector/issues/716 Content-Type: text/plain; charset=utf-8 Noticing some unexpected behavior when I run a query. I am using the following query: ```SQL SELECT *, embedding <=> ('[...]') AS distance FROM public. WHERE embedding <=> ('[...]') < ('1.0'::double precision) ORDER BY distance LIMIT 50 ``` When I run this query, I am only getting 40 results returned. This happens for and LIMIT > 40. However when I go to >= 2575 I am getting the correct number returned. What is going on here, is this a bug? I created the table with the following: ```SQL CREATE EXTENSION IF NOT EXISTS vector; CREATE EXTENSION IF NOT EXISTS hstore; CREATE TABLE IF NOT EXISTS vector_store ( id uuid DEFAULT uuid_generate_v4() PRIMARY KEY, content text, metadata json, embedding vector(1536) // 1536 is the default embedding dimension ); CREATE INDEX ON vector_store USING HNSW (embedding vector_cosine_ops); ``` From noreply+ankane@github.com Fri Nov 22 20:19:42 2024 Message-ID: From: "ankane (@ankane)" To: "pgvector/pgvector" Date: Fri, 22 Nov 2024 20:19:42 +0000 Subject: Re: [pgvector/pgvector] issue #716: LIMIT clause is not Respected > 40 < 2575 In-Reply-To: References: List-Id: X-GitHub-Author-Login: ankane X-GitHub-Comment-Id: 2494728050 X-GitHub-Comment-Type: issue_comment X-GitHub-Issue: 716 X-GitHub-Repo: pgvector/pgvector X-GitHub-Type: comment X-GitHub-Url: https://github.com/pgvector/pgvector/issues/716#issuecomment-2494728050 Content-Type: text/plain; charset=utf-8 Hi @dpresonate, check out the [troubleshooting docs](https://github.com/pgvector/pgvector?tab=readme-ov-file#why-are-there-less-results-for-a-query-after-adding-an-hnsw-index). From noreply+ankane@github.com Fri Nov 22 20:19:42 2024 Message-ID: From: "ankane (@ankane)" To: "pgvector/pgvector" Date: Fri, 22 Nov 2024 20:19:42 +0000 Subject: Re: [pgvector/pgvector] issue #716: LIMIT clause is not Respected > 40 < 2575 In-Reply-To: References: List-Id: X-GitHub-Author-Login: ankane X-GitHub-Event: closed X-GitHub-Event-Id: 15403383491 X-GitHub-Issue: 716 X-GitHub-Repo: pgvector/pgvector X-GitHub-Type: timeline_event Content-Type: text/plain; charset=utf-8 @ankane closed this.