Skip to content

Implement the vchord / pgvector support#350

Merged
nicoloboschi merged 2 commits intovectorize-io:mainfrom
qdrddr:vectorchord
Feb 12, 2026
Merged

Implement the vchord / pgvector support#350
nicoloboschi merged 2 commits intovectorize-io:mainfrom
qdrddr:vectorchord

Conversation

@qdrddr
Copy link
Contributor

@qdrddr qdrddr commented Feb 11, 2026

Implemented the vchord + pgvector support plan from code_update_plan.md. Here are the changes made:

  1. Added _detect_vector_extension() helper function in hindsight-api/hindsight_api/migrations.py (lines 36-65)
  • Detects available vector extension: vchord (preferred) or pgvector
  • Raises RuntimeError if neither extension is found
  • Includes debug logging for the detected extension
  1. Updated ensure_embedding_dimension() function in migrations.py
  • Line 397-398: Added extension detection after engine creation
  • Lines 447-464: Updated index drop logic to handle both HNSW and vchordrq indexes
  • Lines 472-492: Updated index creation to conditionally create:
  • vchordrq index with vector_l2_ops for vchord
  • hnsw index with vector_cosine_ops for pgvector
  • Added debug logging for which index type was created
  1. Updated 5a366d414dce_initial_schema.py migration (lines 203-228)
  • Added inline extension detection
  • Conditional index creation for the memory_units table:
  • vchordrq for vchord
  • HNSW for pgvector
  1. Updated n9i0j1k2l3m4_learnings_and_pinned_reflections.py migration
  • Added from sqlalchemy import text import
  • Added _detect_vector_extension() helper function (lines 31-48)
  • Added extension detection in upgrade() function (line 56)
  • Conditional index creation for learning table (lines 85-95)
  • Conditional index creation for pinned_reflections table (lines 131-141)

Key Features:

  • Backward compatible - Existing pgvector deployments work unchanged
  • Automatic detection - Detects vchord first, falls back to pgvector
  • High-dimensional support - vchord supports embeddings 65K dimensions (e.g., text-embedding-3-large with 3072 dims)
  • Debug logging - Logs which extension is detected on startup
  • Minimal changes - Only index creation/dropping differs between extensions
  • No model changes - Vector type works with both extensions

All code passes linting checks and has no syntax errors.

)
# Create vector index - conditional based on available extension
# Detect which vector extension is available
conn = op.get_bind()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should use detect extension method?

Copy link
Contributor Author

@qdrddr qdrddr Feb 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just wanted to preserve backward compatibility with PGvector for whatever reason in case you want to have it (for example, for licensing reasons):

  • When PGVector -> use HNSW
  • When VectorChord -> use vchordrq index

If you want to completely switch from PGVector to VectorChord, then no need for extention detection.

@qdrddr
Copy link
Contributor Author

qdrddr commented Feb 11, 2026

Added _detect_vector_extension() function @nicoloboschi

@nicoloboschi nicoloboschi merged commit a713b68 into vectorize-io:main Feb 12, 2026
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