As of now, the vector store for PG Vector requires the usage of a read and write endpoint. However, there are situations where read-only functionality is sufficient. Introducing support for read-only endpoints in the vector store would provide the following benefits:
Least Privilege Permissions:
Allowing the use of read-only endpoints enables the principle of least privilege for the database user needed for the vector store. Currently, all instances of the vector store require strong permissions because the vector store always checks the existence of the extension and more. A read-only instance would not need such elevated permissions, enhancing security.
Improved Scalability and Reduced Latency:
PostgreSQL databases typically provide one read-write endpoint and multiple read-only endpoints. Enabling a read-only vector store would allow for more efficient resource usage by distributing the load across multiple read-only endpoints. This can help in scaling out and reducing latency for read operations.
Proposed Change:
Modify the vector store initialization to support read-only endpoints by allowing conditional creation and checking of the vector extension and collection.
Issue Description:
As of now, the vector store for PG Vector requires the usage of a read and write endpoint. However, there are situations where read-only functionality is sufficient. Introducing support for read-only endpoints in the vector store would provide the following benefits:
Least Privilege Permissions:
Improved Scalability and Reduced Latency:
Proposed Change:
Modify the vector store initialization to support read-only endpoints by allowing conditional creation and checking of the vector extension and collection.
Current Code Reference:
https://github.com/langchain-ai/langchain-postgres/blob/88831295acfb7bae3184c124ba82aaf2000dd3a9/langchain_postgres/vectorstores.py#L445-L446