pgcontext
Overview
| Package | Version | Category | License | Language |
|---|---|---|---|---|
pgcontext | 0.2.0 | RAG | Apache-2.0 | Rust |
| ID | Extension | Bin | Lib | Load | Create | Trust | Reloc | Schema |
|---|---|---|---|---|---|---|---|---|
| 1960 | pgcontext | No | Yes | No | Yes | No | No | pgcontext |
| 1970 | pgcontext_pgvector | No | Yes | No | Yes | No | No | - |
| Related | vector vectorize vchord vectorscale pg_rrf pg_search pg_bestmatch vchord_bm25 pgmnemo pg_summarize |
|---|---|
| Depended By | pgcontext_pgvector |
Upstream 0.2.0 and PIGSTY packages support PostgreSQL 17 and 18; pgcontext_pgvector ships in the same package.
Version
| Type | Repo | Version | PG Ver | Package | Deps |
|---|---|---|---|---|---|
| EXT | PIGSTY | 0.2.0 | 1817161514 | pgcontext | - |
| RPM | PIGSTY | 0.2.0 | 1817161514 | pgcontext_$v | - |
| DEB | PIGSTY | 0.2.0 | 1817161514 | postgresql-$v-pgcontext | - |
| OS / PG | PG18 | PG17 | PG16 | PG15 | PG14 |
|---|---|---|---|---|---|
| el8.x86_64 | PIGSTY 0.2.0 el8.x86_64.pg18 : pgcontext_18 pgcontext_18-0.2.0-1PIGSTY.el8.x86_64.rpm
| PIGSTY 0.2.0 el8.x86_64.pg17 : pgcontext_17 pgcontext_17-0.2.0-1PIGSTY.el8.x86_64.rpm
| N/A | N/A | N/A |
| el8.aarch64 | PIGSTY 0.2.0 el8.aarch64.pg18 : pgcontext_18 pgcontext_18-0.2.0-1PIGSTY.el8.aarch64.rpm
| PIGSTY 0.2.0 el8.aarch64.pg17 : pgcontext_17 pgcontext_17-0.2.0-1PIGSTY.el8.aarch64.rpm
| N/A | N/A | N/A |
| el9.x86_64 | PIGSTY 0.2.0 el9.x86_64.pg18 : pgcontext_18 pgcontext_18-0.2.0-1PIGSTY.el9.x86_64.rpm
| PIGSTY 0.2.0 el9.x86_64.pg17 : pgcontext_17 pgcontext_17-0.2.0-1PIGSTY.el9.x86_64.rpm
| N/A | N/A | N/A |
| el9.aarch64 | PIGSTY 0.2.0 el9.aarch64.pg18 : pgcontext_18 pgcontext_18-0.2.0-1PIGSTY.el9.aarch64.rpm
| PIGSTY 0.2.0 el9.aarch64.pg17 : pgcontext_17 pgcontext_17-0.2.0-1PIGSTY.el9.aarch64.rpm
| N/A | N/A | N/A |
| el10.x86_64 | PIGSTY 0.2.0 el10.x86_64.pg18 : pgcontext_18 pgcontext_18-0.2.0-1PIGSTY.el10.x86_64.rpm
| PIGSTY 0.2.0 el10.x86_64.pg17 : pgcontext_17 pgcontext_17-0.2.0-1PIGSTY.el10.x86_64.rpm
| N/A | N/A | N/A |
| el10.aarch64 | PIGSTY 0.2.0 el10.aarch64.pg18 : pgcontext_18 pgcontext_18-0.2.0-1PIGSTY.el10.aarch64.rpm
| PIGSTY 0.2.0 el10.aarch64.pg17 : pgcontext_17 pgcontext_17-0.2.0-1PIGSTY.el10.aarch64.rpm
| N/A | N/A | N/A |
| d12.x86_64 | PIGSTY 0.2.0 d12.x86_64.pg18 : postgresql-18-pgcontext postgresql-18-pgcontext_0.2.0-1PIGSTY~bookworm_amd64.deb
| PIGSTY 0.2.0 d12.x86_64.pg17 : postgresql-17-pgcontext postgresql-17-pgcontext_0.2.0-1PIGSTY~bookworm_amd64.deb
| N/A | N/A | N/A |
| d12.aarch64 | PIGSTY 0.2.0 d12.aarch64.pg18 : postgresql-18-pgcontext postgresql-18-pgcontext_0.2.0-1PIGSTY~bookworm_arm64.deb
| PIGSTY 0.2.0 d12.aarch64.pg17 : postgresql-17-pgcontext postgresql-17-pgcontext_0.2.0-1PIGSTY~bookworm_arm64.deb
| N/A | N/A | N/A |
| d13.x86_64 | PIGSTY 0.2.0 d13.x86_64.pg18 : postgresql-18-pgcontext postgresql-18-pgcontext_0.2.0-1PIGSTY~trixie_amd64.deb
| PIGSTY 0.2.0 d13.x86_64.pg17 : postgresql-17-pgcontext postgresql-17-pgcontext_0.2.0-1PIGSTY~trixie_amd64.deb
| N/A | N/A | N/A |
| d13.aarch64 | PIGSTY 0.2.0 d13.aarch64.pg18 : postgresql-18-pgcontext postgresql-18-pgcontext_0.2.0-1PIGSTY~trixie_arm64.deb
| PIGSTY 0.2.0 d13.aarch64.pg17 : postgresql-17-pgcontext postgresql-17-pgcontext_0.2.0-1PIGSTY~trixie_arm64.deb
| N/A | N/A | N/A |
| u22.x86_64 | PIGSTY 0.2.0 u22.x86_64.pg18 : postgresql-18-pgcontext postgresql-18-pgcontext_0.2.0-1PIGSTY~jammy_amd64.deb
| PIGSTY 0.2.0 u22.x86_64.pg17 : postgresql-17-pgcontext postgresql-17-pgcontext_0.2.0-1PIGSTY~jammy_amd64.deb
| N/A | N/A | N/A |
| u22.aarch64 | PIGSTY 0.2.0 u22.aarch64.pg18 : postgresql-18-pgcontext postgresql-18-pgcontext_0.2.0-1PIGSTY~jammy_arm64.deb
| PIGSTY 0.2.0 u22.aarch64.pg17 : postgresql-17-pgcontext postgresql-17-pgcontext_0.2.0-1PIGSTY~jammy_arm64.deb
| N/A | N/A | N/A |
| u24.x86_64 | PIGSTY 0.2.0 u24.x86_64.pg18 : postgresql-18-pgcontext postgresql-18-pgcontext_0.2.0-1PIGSTY~noble_amd64.deb
| PIGSTY 0.2.0 u24.x86_64.pg17 : postgresql-17-pgcontext postgresql-17-pgcontext_0.2.0-1PIGSTY~noble_amd64.deb
| N/A | N/A | N/A |
| u24.aarch64 | PIGSTY 0.2.0 u24.aarch64.pg18 : postgresql-18-pgcontext postgresql-18-pgcontext_0.2.0-1PIGSTY~noble_arm64.deb
| PIGSTY 0.2.0 u24.aarch64.pg17 : postgresql-17-pgcontext postgresql-17-pgcontext_0.2.0-1PIGSTY~noble_arm64.deb
| N/A | N/A | N/A |
| u26.x86_64 | PIGSTY 0.2.0 u26.x86_64.pg18 : postgresql-18-pgcontext postgresql-18-pgcontext_0.2.0-1PIGSTY~resolute_amd64.deb
| PIGSTY 0.2.0 u26.x86_64.pg17 : postgresql-17-pgcontext postgresql-17-pgcontext_0.2.0-1PIGSTY~resolute_amd64.deb
| N/A | N/A | N/A |
| u26.aarch64 | PIGSTY 0.2.0 u26.aarch64.pg18 : postgresql-18-pgcontext postgresql-18-pgcontext_0.2.0-1PIGSTY~resolute_arm64.deb
| PIGSTY 0.2.0 u26.aarch64.pg17 : postgresql-17-pgcontext postgresql-17-pgcontext_0.2.0-1PIGSTY~resolute_arm64.deb
| N/A | N/A | N/A |
Build
You can build the RPM / DEB packages for pgcontext using pig build:
pig build pkg pgcontext # build RPM / DEB packages
Install
You can install pgcontext directly. First, make sure the PGDG and PIGSTY repositories are added and enabled:
pig repo add pgsql -u # Add repo and update cache
Install the extension using pig or apt/yum/dnf:
pig install pgcontext; # Install for current active PG version
pig ext install -y pgcontext -v 18 # PG 18
pig ext install -y pgcontext -v 17 # PG 17
dnf install -y pgcontext_18 # PG 18
dnf install -y pgcontext_17 # PG 17
apt install -y postgresql-18-pgcontext # PG 18
apt install -y postgresql-17-pgcontext # PG 17
Create Extension:
CREATE EXTENSION pgcontext;
Usage
Sources:
- pgContext 0.2.0 README
- pgContext 0.2.0 release notes
- pgContext collection quickstart
- pgContext index guide
- pgContext known limitations
- pgContext control file
- pgvector coexistence guide
pgcontext keeps vector and hybrid retrieval inside PostgreSQL. It provides pgContext-owned vector types, collection metadata over application tables, registered-field filters, exact search, persisted HNSW, and dense plus full-text fusion. Application rows remain authoritative for MVCC, ACL/RLS, backup, and replication; indexes and generated artifacts are rebuildable acceleration state.
Version 0.2.0 targets PostgreSQL 17 and 18, with the release’s controlled-pilot qualification centered on PostgreSQL 17. Advanced HNSW, non-dense, quantized, mapped, and late-interaction paths retain explicit experimental boundaries.
Core Workflow
CREATE EXTENSION pgcontext;
CREATE TABLE public.docs (
id text PRIMARY KEY,
embedding pgcontext.vector(2) NOT NULL,
status text NOT NULL,
body text NOT NULL,
metadata jsonb NOT NULL
);
INSERT INTO public.docs (id, embedding, status, body, metadata) VALUES
('doc-1', '[1,0]'::pgcontext.vector, 'published', 'postgres vector search', '{"topic":"postgres"}'),
('doc-2', '[0,1]'::pgcontext.vector, 'published', 'rust extension guide', '{"topic":"rust"}');
SELECT * FROM pgcontext.create_collection('docs', 'public.docs');
SELECT pgcontext.register_vector('docs', 'embedding', 'embedding', 2, 'l2');
SELECT pgcontext.register_filter_column('docs', 'status', 'status');
SELECT pgcontext.register_jsonb_path('docs', 'topic', 'metadata', ARRAY['topic']);
SELECT pgcontext.upsert_points('docs', ARRAY['doc-1', 'doc-2']);
SELECT source_key, score
FROM pgcontext.search(
'docs',
'[1,0]'::pgcontext.vector,
'{"must":[{"key":"status","match":"published"}]}'::jsonb,
10
);
Collections describe application-owned tables; they do not copy those rows into another authoritative store. Search, count, facets, grouping, scrolling, recommendation, and discovery share registered vector and filter definitions.
HNSW and Hybrid Retrieval
SET maintenance_work_mem = '2GB';
CREATE INDEX docs_embedding_hnsw ON public.docs
USING pgcontext_hnsw
(embedding pgcontext.vector_hnsw_cosine_ops);
RESET maintenance_work_mem;
SELECT source_key, score
FROM pgcontext.query(
'docs',
'[1,0]'::pgcontext.vector,
'postgres search',
'body',
10
);
Dense HNSW operator classes cover L2, inner product, cosine, and L1. Index builds enforce maintenance_work_mem; size the build budget first, then compare approximate results with exact search and pgcontext.recall_check. pgcontext.query combines dense and PostgreSQL full-text branches with reciprocal-rank fusion.
Important Objects
pgcontext.vector,pgcontext.halfvec,pgcontext.sparsevec, andpgcontext.bitvecare extension-owned types; the non-dense variants remain experimental.pgcontext.create_collection, registration functions, and point-mapping functions define the retrieval contract over source tables.pgcontext.search,count,facet,scroll,grouped_search,recommend, anddiscoverprovide table-backed retrieval.pgcontext.queryandexplainexpose composable and hybrid retrieval.pgcontext_hnswplus metric-specific operator classes provide ANN indexing.- Index status, diagnostics, vacuum advice, recall checks, optimization status, and bounded telemetry support operational review.
Upgrade and pgvector Boundary
Version 0.2.0 moves pgContext-owned types into the fixed pgcontext schema. Existing standalone 0.1.0 installations can use the packaged update as a superuser:
ALTER EXTENSION pgcontext UPDATE TO '0.2.0';
Afterward, qualify types such as pgcontext.vector(1536) or deliberately add the schema to search_path. A 0.1.0 database where public vector types are owned by pgvector is rejected before mutation; inventory dependencies, install 0.2.0 and the separate pgcontext_pgvector bridge, recreate registrations and dependents, and rebuild pgContext indexes over the unchanged pgvector columns.
The main extension has no dependency on pgvector. Its types are distinct from public.vector, public.halfvec, and public.sparsevec; do not assume install order aliases one extension’s types to the other.
Operational Boundaries
CREATE EXTENSIONand updates require a PostgreSQL superuser because pgContext installs an access method. Granted application APIs do not require superuser.- No
shared_preload_libraries,LOAD, or restart is required by the main extension. - The early-release HNSW on-disk format is not stable; plan and validate index rebuilds across releases rather than treating index files as portable data.
- Exact reranking, MVCC, ACL, and RLS checks remain correctness boundaries, but they do not replace workload-specific recall, latency, restart, VACUUM, replication, and failure testing.
- Remove collection registrations and inspect dependent application objects before dropping the extension; avoid unreviewed
CASCADE.
Feedback
Was this page helpful?
Thanks for the feedback! Please let us know how we can improve.
Sorry to hear that. Please let us know how we can improve.