mirror of
https://github.com/open-webui/open-webui.git
synced 2026-05-08 04:16:03 -05:00
[GH-ISSUE #16887] feat: add env var support for pgvector hnsw index type #33616
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @dlamoris on GitHub (Aug 25, 2025).
Original GitHub issue: https://github.com/open-webui/open-webui/issues/16887
Check Existing Issues
Problem Description
Currently the pgvector db init code is hardcoded to use the IVFFLAT index type:
Since pgvector 0.5.0 HNSW index type is available and seems to be a better choice (ref https://stormatics.tech/blogs/understanding-indexes-in-pgvector and https://aws.amazon.com/blogs/database/optimize-generative-ai-applications-with-pgvector-indexing-a-deep-dive-into-ivfflat-and-hnsw-techniques/), index type should be configurable via env var.
TLDR: ivfflat index type is best done when there are already existing data and would need to be reindexed periodically when there's new data, while hnsw index type can be created anytime and give more accurate results (with the drawback of using more memory)
Desired Solution you'd like
Add env var for pgvector db option to configure vector index type and any other related options (like m, ef_construction)
Alternatives Considered
Do nothing and let deployer delete/recreate/maintain indexes directly with postgres
Additional Context
No response
@tjbck commented on GitHub (Aug 25, 2025):
PR welcome!