mirror of
https://github.com/pgvector/pgvector.git
synced 2026-06-06 05:51:21 +08:00
38 lines
1.2 KiB
Plaintext
38 lines
1.2 KiB
Plaintext
SET enable_seqscan = off;
|
|
-- hamming
|
|
CREATE TABLE t (val bit(3));
|
|
INSERT INTO t (val) VALUES (B'000'), (B'100'), (B'111'), (NULL);
|
|
CREATE INDEX ON t USING ivfflat (val bit_hamming_ops) WITH (lists = 1);
|
|
INSERT INTO t (val) VALUES (B'110');
|
|
SELECT * FROM t ORDER BY val <~> B'111';
|
|
val
|
|
-----
|
|
111
|
|
110
|
|
100
|
|
000
|
|
(4 rows)
|
|
|
|
SELECT COUNT(*) FROM (SELECT * FROM t ORDER BY val <~> (SELECT NULL::bit)) t2;
|
|
count
|
|
-------
|
|
4
|
|
(1 row)
|
|
|
|
DROP TABLE t;
|
|
-- varbit
|
|
CREATE TABLE t (val varbit(3));
|
|
CREATE INDEX ON t USING ivfflat (val bit_hamming_ops) WITH (lists = 1);
|
|
ERROR: type not supported for ivfflat index
|
|
CREATE INDEX ON t USING ivfflat ((val::bit(3)) bit_hamming_ops) WITH (lists = 1);
|
|
NOTICE: ivfflat index created with little data
|
|
DETAIL: This will cause low recall.
|
|
HINT: Drop the index until the table has more data.
|
|
CREATE INDEX ON t USING ivfflat ((val::bit(64001)) bit_hamming_ops) WITH (lists = 1);
|
|
ERROR: column cannot have more than 64000 dimensions for ivfflat index
|
|
CREATE INDEX ON t USING ivfflat ((val::bit(2)) bit_hamming_ops) WITH (lists = 5);
|
|
NOTICE: ivfflat index created with little data
|
|
DETAIL: This will cause low recall.
|
|
HINT: Drop the index until the table has more data.
|
|
DROP TABLE t;
|