Comments (2)
Hey @zhihongx0, multi-column support would be pretty difficult and I think is outside the scope of IVFFlat indexes (and pgvector doesn't support GiST), but there are two strategies you can use to efficiently query on conditions:
- Use a partial index
CREATE INDEX ON table USING ivfflat (column) WHERE (other_column = 123);
- If you need to query on many different values of
other_column
, it should be more efficient to partition the table onother_column
(so each partition will get a separate IVFFlat index)
from pgvector.
Added this info to the readme.
Here's a quick example for partitioning with Postgres 13 (should work with range, list, and hash).
CREATE EXTENSION IF NOT EXISTS vector;
DROP TABLE IF EXISTS items;
CREATE TABLE items (
id bigserial,
factors vector(3),
category_id bigint
) PARTITION BY HASH(category_id);
CREATE TABLE items_part1 PARTITION OF items FOR VALUES WITH (modulus 3, remainder 0);
CREATE TABLE items_part2 PARTITION OF items FOR VALUES WITH (modulus 3, remainder 1);
CREATE TABLE items_part3 PARTITION OF items FOR VALUES WITH (modulus 3, remainder 2);
INSERT INTO items (factors, category_id) SELECT ARRAY[RANDOM(), RANDOM(), RANDOM()], n % 10 FROM generate_series(1, 100000) n;
CREATE INDEX ON items USING ivfflat (factors);
SELECT * FROM items WHERE category_id = 2 ORDER BY factors <-> '[0.5,0.5,0.5]' LIMIT 5;
EXPLAIN ANALYZE SELECT * FROM items WHERE category_id = 2 ORDER BY factors <-> '[0.5,0.5,0.5]' LIMIT 5;
from pgvector.
Related Issues (20)
- Does ivvflat index has max query result limit? HOT 2
- Query not using IVFFLAT index HOT 4
- Indexing parts of vector separately and together HOT 5
- [Question]Need help with the pgvector Installation with pgAdmin & version mismatch error HOT 9
- Parallel index builds for HNSW HOT 21
- Postgresql and pgvector: the extention vector is not available HOT 1
- [BUG] extension "pgvector" is not available HOT 2
- Drop support for PostgreSQL v11 HOT 3
- Use Array as vector type? HOT 1
- pgvector does not work for multi-schema postgresql DBs HOT 2
- Can HNSW/ IVVFlat INDEXES co exist? HOT 1
- Multi-User or Multi-Tenancy HOT 1
- Embedding precision in Vector data type HOT 2
- Pgvector v0.5.1 compatibility with PostgreSQL 16.1 - MacOS HOT 1
- Querying variable dimension vector with pgvector 0.5.1 HOT 2
- `ERROR: different vector dimensions` When there are vectors of different dimensions HOT 1
- Support For Hamming Distance HOT 8
- HNSW Indexing Times Issue HOT 1
- Error creating index on materialized view HOT 2
- Follow up #425 - pgvector issues with postgresql 16.1 on macOS Sonoma HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pgvector.