Created
November 16, 2023 00:44
-
-
Save ankane/2ea49423534051eb76565435e76b4b83 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# CREATE INDEX output omitted | |
psql:repro.sql:8: INFO: vector_l2_squared_distance | |
psql:repro.sql:8: INFO: vector_l2_squared_distance | |
psql:repro.sql:8: INFO: vector_l2_squared_distance | |
psql:repro.sql:8: INFO: vector_l2_squared_distance | |
psql:repro.sql:8: INFO: vector_l2_squared_distance | |
psql:repro.sql:8: INFO: l2_distance | |
psql:repro.sql:8: INFO: l2_distance | |
id | |
---- | |
1 | |
2 | |
(2 rows) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/src/vector.c b/src/vector.c | |
index 2f1e886..bf6c01a 100644 | |
--- a/src/vector.c | |
+++ b/src/vector.c | |
@@ -563,6 +563,8 @@ l2_distance(PG_FUNCTION_ARGS) | |
float distance = 0.0; | |
float diff; | |
+ elog(INFO, "l2_distance"); | |
+ | |
CheckDims(a, b); | |
/* Auto-vectorized */ | |
@@ -590,6 +592,8 @@ vector_l2_squared_distance(PG_FUNCTION_ARGS) | |
float distance = 0.0; | |
float diff; | |
+ elog(INFO, "vector_l2_squared_distance"); | |
+ | |
CheckDims(a, b); | |
/* Auto-vectorized */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SET enable_seqscan = off; | |
DROP TABLE IF EXISTS items; | |
CREATE TABLE items (id bigserial primary key, embedding vector(3)); | |
INSERT INTO items (embedding) VALUES ('[0,0,0]'), ('[1,1,1]'), ('[2,2,2]'), ('[3,3,3]'); | |
CREATE INDEX ON items USING ivfflat (embedding vector_l2_ops) WITH (lists = 1); | |
SELECT id FROM items ORDER BY embedding <-> '[0,0,0]' LIMIT 2; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment