From: avulasaikiran (@avulasaikiran) <noreply+avulasaikiran@github.com>
To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>
Subject: [pgvector/pgvector] issue #664: difference in output with seq scan and index scan on vector column.
Date: Fri, 30 Aug 2024 07:49:18 +0000
Message-ID: <gh-pgvector-pgvector-664@github.com> (raw)
Hi,
I am seeing following behavior with vector extension. Is this expected or is this a known issue?
postgres=# set enable_seqscan = on;
SET
postgres=# SELECT * FROM t ORDER BY val <=> (SELECT NULL::vector);
id | val
----+---------
1 | [0,0,0]
2 | [1,2,3]
3 | [1,1,1]
4 |
5 | [1,2,4]
(5 rows)
postgres=#
postgres=#
postgres=# set enable_seqscan = off;
SET
postgres=# SELECT * FROM t ORDER BY val <=> (SELECT NULL::vector);
id | val
----+---------
2 | [1,2,3]
3 | [1,1,1]
5 | [1,2,4]
(3 rows)
Following is my setup:
CREATE EXTENSION vector;
CREATE TABLE t (id SERIAL, val vector(3));
CALL rds_aurora.limitless_table_alter_type_sharded_and_wait('t', ARRAY['id']);
INSERT INTO t (val) VALUES ('[0,0,0]'), ('[1,2,3]'), ('[1,1,1]'), (NULL);
CREATE INDEX ON t USING ivfflat (val vector_cosine_ops) WITH (lists = 1);
INSERT INTO t (val) VALUES ('[1,2,4]');
postgres=# select * from pg_extension where extname = 'vector';
oid | extname | extowner | extnamespace | extrelocatable | extversion | extconfig | extcondition
-------+---------+----------+--------------+----------------+------------+-----------+--------------
16403 | vector | 10 | 2200 | t | 0.7.3 | |
(1 row)