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.

Build with AI
- Copy the prompt below
- Paste into Cursor, Claude Code, Codex, or any coding agent
- 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. Anot enablederror means Lakebase is not available to this identity. - A provisioned Lakebase project. Complete the Create a Lakebase Instance template first. You will enable the
vectorextension against its primary endpoint. databricks psqlavailable in your CLI. Rundatabricks psql --helpand confirm the subcommand exists. If it does not, upgrade the Databricks CLI (see Set Up Your Local Dev Environment).


