Find answers from the community

Updated 2 months ago

Postgres

Hi, when running the example at https://docs.llamaindex.ai/en/latest/examples/vector_stores/postgres.html , no HNSW index gets created on the embedding column. Do i need to add it manually or am I missing something? Thanks!
L
a
3 comments
I think it by default uses ivflat?

Tbh if you notice any issues with the code here, I'd love to have a PR to improve it
https://github.com/run-llama/llama_index/blob/936c42f318a95eb55a40749f7946c641344baad4/llama_index/vector_stores/postgres.py#L27
Hi

After creating the database, one should run CREATE EXTENSION vector; to enable the extension on the newly created database and then, for example, CREATE INDEX ON {table_name} USING hnsw ({field_name} vector_l2_ops) WITH (m = 16, ef_construction = 64); to create the index. As far as I understand, there is no default index.
If you can add a PR to add that, that would be very helpful

Right now the vector extension is created here
https://github.com/run-llama/llama_index/blob/936c42f318a95eb55a40749f7946c641344baad4/llama_index/vector_stores/postgres.py#L291
Add a reply
Sign up and join the conversation on Discord