Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improving Recall When Filtering on very small subset #119

Closed
ggalpra opened this issue Feb 20, 2025 · 1 comment
Closed

Improving Recall When Filtering on very small subset #119

ggalpra opened this issue Feb 20, 2025 · 1 comment

Comments

@ggalpra
Copy link

ggalpra commented Feb 20, 2025

Hi,

I'm encountering an issue with my PostgreSQL + PGVector setup:

I have a table containing vectors and a category_id, and I always need to filter on a specific category_id. However, since I have hundreds of different categories and the filtering is applied after the index scan, it leads to very low recall in my queries.

I understand that partitioning is recommended in such cases, but my challenge is that new category_id values are frequently added, and I need efficient indexing on them immediately for performance reasons.

I'm using Django, and due to external constraints, I'm stuck on PostgreSQL 16.3, meaning I can't upgrade pgvector to 0.8.0 to leverage iterative scanning.

Has anyone faced a similar issue? How did you manage to improve recall in this scenario?

Thanks!

@ankane
Copy link
Member

ankane commented Feb 20, 2025

Hi @ggalpra, check out the filtering docs for a list of options. I'd start with a B-tree index on category_id. For iterative scanning, pgvector 0.8.0 supports Postgres 13+, and for partitioning, you can use hash partitioning if categories are frequently added.

@ankane ankane closed this as completed Feb 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants