Skip to content

fix: Use JSONB for metadata column instead of JSON #230

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

cedrickrusche
Copy link

This pull request updates the metadata column type from JSON to JSONB in the PGVector table creation logic.

📌 Motivation

The LangChain documentation recommends using the JSONB type for metadata storage due to its performance and indexing advantages. However, the current implementation defaults to JSON, which does not align with this guidance.

✅ Changes

Replaces:

query += f""",\n"{metadata_json_column}" JSON"""

with

query += f""",\n"{metadata_json_column}" JSONB"""

📎 Notes

This change does not affect existing tables.

@averikitsch
Copy link
Collaborator

Thank you @cedrickrusche for the PR. The JSON data type has faster insertion performance. We recommend that any metadata that should be indexed and filtered on to be specified as specific "metadata_columns" for even better performance than using JSONB.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants