Skip to main content

Lakebase pgvector

Enable vector similarity search in Lakebase using the pgvector extension. Covers extension setup, vector table design, insert and cosine retrieval helpers, and IVFFlat/HNSW index options.

Lakebase pgvector preview

Build with AI

  1. Copy the prompt below
  2. Paste into Cursor, Claude Code, Codex, or any coding agent
  3. Your agent builds it — asking questions along the way so the result is exactly what you want

New to templates? Learn more here

When done, you will have:

  • The pgvector extension enabled on your Lakebase instance
  • A vector embedding table with configurable dimensions
  • Server-side functions for inserting documents and performing similarity search
  • An IVFFlat or HNSW index for efficient nearest-neighbor queries

Prerequisites

Verify these Databricks workspace features are enabled before starting. If any check fails, ask your workspace admin to enable the feature.

  • Lakebase Postgres available. Run databricks postgres list-projects --profile <PROFILE> and confirm the command succeeds. A not enabled error means Lakebase is not available to this identity.
  • A provisioned Lakebase project. Complete the Create a Lakebase Instance template first. You will enable the vector extension against its primary endpoint.
  • databricks psql available in your CLI. Run databricks psql --help and confirm the subcommand exists. If it does not, upgrade the Databricks CLI (see Set Up Your Local Dev Environment).