Pg_vectorsearch: An index that is faster than pgvector's IVFFlat and HNSW
Recorded: Oct. 14, 2026, 12:10 p.m.
| Original | Summarized |
GitHub - timescale/pg_vectorsearch: High-performance vector search for PostgreSQL · GitHub Skip to content Navigation MenuSign inAppearance settingsPlatformAI CODE CREATIONGitHub CopilotWrite better code with AIGitHub Copilot appDirect agents from issue to mergeMCP RegistryIntegrate external toolsDEVELOPER WORKFLOWSActionsAutomate any workflowCodespacesInstant dev environmentsIssuesPlan and track workCode ReviewManage code changesCode QualityEnforce quality at mergeAPPLICATION SECURITYGitHub Advanced SecurityFind and fix vulnerabilitiesCode securitySecure your code as you buildSecret protectionStop leaks before they startEXPLOREWhy GitHubDocumentationBlogChangelogMarketplaceView all featuresSolutionsBY COMPANY SIZEEnterprisesSmall and medium teamsStartupsNonprofitsBY USE CASEApp ModernizationDevSecOpsDevOpsCI/CDView all use casesBY INDUSTRYHealthcareFinancial servicesManufacturingGovernmentView all industriesView all solutionsResourcesEXPLORE BY TOPICAISoftware DevelopmentDevOpsSecurityView all topicsEXPLORE BY TYPECustomer storiesEvents & webinarsEbooks & reportsBusiness insightsGitHub SkillsSUPPORT & SERVICESDocumentationCustomer supportCommunity forumTrust centerPartnersView all resourcesOpen SourceCOMMUNITYGitHub SponsorsFund open source developersPROGRAMSSecurity LabMaintainer CommunityGitHub StarsArchive ProgramREPOSITORIESTopicsTrendingCollectionsEnterpriseENTERPRISE SOLUTIONSEnterprise platformAI-powered developer platformAVAILABLE ADD-ONSGitHub Advanced SecurityEnterprise-grade security featuresCopilot for BusinessEnterprise-grade AI featuresPremium SupportEnterprise-grade 24/7 supportPricingSearch/Sign inSign upAppearance settings You signed in with another tab or window. Reload to refresh your session. Dismiss alert timescalepg_vectorsearchRepository navigationCodeIssues29 (29)Pull requests8 (8)DiscussionsActionsProjectsSecurity and qualityInsightsMore items pg_vectorsearchPublicNotificationsYou must be signed in to change notification settingsFork5 (5)Star76 (76)You must be signed in to star a repositoryAboutHigh-performance vector search for PostgreSQLResourcesReadmePostgreSQL licenseActivityCustom propertiesStars76 starsWatchers1 watchingForks5 forksReport repositorymainBranchesTagsGo to fileCodeOpen more actions menuLatest commit History437 Commits437 CommitsFolders and filesNameNameLast commit messageLast commit date.claude/skills.claude/skills .github.github docsdocs imagesimages scriptsscripts sqlsql srcsrc testtest third-partythird-party .clang-format.clang-format .clang-format-ignore.clang-format-ignore .clang-tidy.clang-tidy .clangd.clangd .commitlintrc.yaml.commitlintrc.yaml .gitattributes.gitattributes .gitignore.gitignore .markdownlint.json.markdownlint.json .pre-commit-config.yaml.pre-commit-config.yaml .release-notes-template.md.release-notes-template.md .squawk.toml.squawk.toml AGENTS.mdAGENTS.md CHANGELOG.mdCHANGELOG.md CLAUDE.mdCLAUDE.md LICENSELICENSE MakefileMakefile README.mdREADME.md VERSIONVERSION clang-format-ignore.inclang-format-ignore.in cliff.tomlcliff.toml meson.buildmeson.build meson_options.txtmeson_options.txt pg_vectorsearch.control.inpg_vectorsearch.control.in renovate.jsonrenovate.json View all filesRepository files navigationREADMEPostgreSQL licenseMore itemspg_vectorsearch A PostgreSQL extension for high-performance approximate nearest neighbor (ANN) Status: alpha. Meant for testing, not production. Upgrading PRISM index (100M+ vectors) — IVF-style, with hierarchical routing PRISM Index PRISM (Partitioned Routing Index for Similarity Matching) is a PostgreSQL-native For detailed architecture, see docs/architecture.md. Native types. Starting fresh, or not using Both paths build the same index and use the same operators (<->, -- PLAIN keeps the vector inline. EXTERNAL (the default) toasts a value -- Load first; the index is sized from the row count at CREATE INDEX. -- For inner product or cosine, see Operator classes below. -- 0 = auto (~0.95 recall). Raise for recall, lower for speed. SELECT * FROM items CREATE TABLE documents ( -- Install pg_vectorsearch next to pgvector and build the index on the CREATE INDEX documents_embedding_prism -- Your queries keep working as before. PRISM is normally faster, so -- Once you are happy with it, drop the HNSW index. Distance L2 Inner product Cosine When replacing an HNSW index, pgvector's vector_<metric>_ops maps to PostgreSQL 18+ (with development headers) # Release build # Build and install to PostgreSQL Tuning - Index parameters, GUCs, tradeoffs, defaults References RaBitQ - Binary quantization with theoretical error bounds Related Projects pgvector - Vector type and operators for PostgreSQL License Footer © 2026 GitHub, Inc. Footer navigation Terms Privacy Security Status Community Docs Contact Manage cookies Do not share my personal information You can’t perform that action at this time. |
The pg_vectorsearch repository introduces a PostgreSQL extension designed to facilitate high-performance approximate nearest neighbor (ANN) search capabilities. At its core, the project implements the PRISM index, which is a PostgreSQL-native access method conceptually similar to pgvector's IVFFlat but built upon advanced quantization, routing, and partitioning techniques. This implementation is written in C to ensure high performance and seamless integration within the PostgreSQL environment. The PRISM index achieves superior performance compared to methods like pgvector's IVFFlat and HNSW for both querying and index building. For instance, the system demonstrates speed advantages, achieving equivalent recall on a one-hundred-million-vector dataset while utilizing only a quarter of the memory required by graph-based HNSW structures. This performance gain is realized through several architectural choices. PRISM employs a hierarchical centroid tree to partition vectors into clusters, leveraging the PostgreSQL buffer cache to maintain this tree in memory. Vectors are further optimized by being RaBitQ-quantized, which involves encoding vectors using theoretical error bounds to allow the system to preemptively rule out vectors that cannot be nearest neighbors, thus reducing the necessity for full-precision reranking. The data is stored in posting lists with a page layout optimized for efficient SIMD distance computation using instructions like AVX2, AVX512, and NEON. The query flow for a PRISM index involves a multi-stage process: first, traversing the centroid tree to locate the nearest clusters; second, scanning the corresponding posting lists for candidate vectors using the buffer cache and asynchronous input/output; third, performing a RaBitQ two-stage filtering process based on error estimation and bounds; fourth, executing full-precision reranking against the vectors stored in the heap; and finally, returning the top k nearest neighbors. The implementation supports flexibility in how vectors are stored. Users have two primary paths for deployment: storing vectors in native columns within pg_vectorsearch, or building the index directly on existing vector or halfvec columns already present in pgvector tables. Both paths ultimately yield the same index structure and utilize consistent operators for distance metrics. The system defines specific operator classes for various distance metrics, including L2, inner product, and cosine similarity, which map to specific vector types such as vec32 and vec16. Maintenance of the index is handled dynamically through posting lists, where inserts and updates append vectors to relevant lists. To manage growing lists without slow splitting operations, the system includes the prism_rebalance procedure, which splits oversized lists in place. Beyond indexing, the framework provides detailed options for tuning index parameters and Generalized Uncommitted Control (GUC) settings, which are based on large-scale benchmark results. The development requires specific compiler and build system prerequisites, including PostgreSQL version 18 or later, a GNU C11 compiler (GCC 11+ or Clang 14+), and the Meson build system. The repository also references foundational research in approximate nearest neighbor search, including concepts from RaBitQ quantization, incremental update protocols, and hierarchical clustering methods. This foundation places pg_vectorsearch within the context of advanced machine learning algorithms applied to database indexing. |