pg_sorted_heap
pg_sorted_heap : Sorted heap table AM with zone map scan pruning and built-in vector search
Overview
| ID | Extension | Package | Version | Category | License | Language |
|---|---|---|---|---|---|---|
| 2550 | pg_sorted_heap | pg_sorted_heap | 0.14.0 |
OLAP | PostgreSQL | C |
| Attribute | Has Binary | Has Library | Need Load | Has DDL | Relocatable | Trusted |
|---|---|---|---|---|---|---|
| --sLd-- | No | Yes | Yes | Yes | no | no |
| Relationships | |
|---|---|
| See Also | pg_mooncake storage_engine columnar orioledb citus_columnar |
Packages
| Type | Repo | Version | PG Major Compatibility | Package Pattern | Dependencies |
|---|---|---|---|---|---|
| EXT | PIGSTY | 0.14.0 |
18 17 16 15 14 | pg_sorted_heap |
- |
| RPM | PIGSTY | 0.14.0 |
18 17 16 15 14 | pg_sorted_heap_$v |
- |
| DEB | PIGSTY | 0.14.0 |
18 17 16 15 14 | postgresql-$v-pg-sorted-heap |
- |
| Linux / PG | PG18 | PG17 | PG16 | PG15 | PG14 |
|---|---|---|---|---|---|
| el8.x86_64 | PIGSTY 0.14.0 | PIGSTY 0.14.0 | PIGSTY 0.14.0 | N/A | N/A |
| el8.aarch64 | PIGSTY 0.14.0 | PIGSTY 0.14.0 | PIGSTY 0.14.0 | N/A | N/A |
| el9.x86_64 | PIGSTY 0.14.0 | PIGSTY 0.14.0 | PIGSTY 0.14.0 | N/A | N/A |
| el9.aarch64 | PIGSTY 0.14.0 | PIGSTY 0.14.0 | PIGSTY 0.14.0 | N/A | N/A |
| el10.x86_64 | PIGSTY 0.14.0 | PIGSTY 0.14.0 | PIGSTY 0.14.0 | N/A | N/A |
| el10.aarch64 | PIGSTY 0.14.0 | PIGSTY 0.14.0 | PIGSTY 0.14.0 | N/A | N/A |
| d12.x86_64 | PIGSTY 0.14.0 | PIGSTY 0.14.0 | PIGSTY 0.14.0 | N/A | N/A |
| d12.aarch64 | PIGSTY 0.14.0 | PIGSTY 0.14.0 | PIGSTY 0.14.0 | N/A | N/A |
| d13.x86_64 | PIGSTY 0.14.0 | PIGSTY 0.14.0 | PIGSTY 0.14.0 | N/A | N/A |
| d13.aarch64 | PIGSTY 0.14.0 | PIGSTY 0.14.0 | PIGSTY 0.14.0 | N/A | N/A |
| u22.x86_64 | PIGSTY 0.14.0 | PIGSTY 0.14.0 | PIGSTY 0.14.0 | N/A | N/A |
| u22.aarch64 | PIGSTY 0.14.0 | PIGSTY 0.14.0 | PIGSTY 0.14.0 | N/A | N/A |
| u24.x86_64 | PIGSTY 0.14.0 | PIGSTY 0.14.0 | PIGSTY 0.14.0 | N/A | N/A |
| u24.aarch64 | PIGSTY 0.14.0 | PIGSTY 0.14.0 | PIGSTY 0.14.0 | N/A | N/A |
| u26.x86_64 | PIGSTY 0.14.0 | PIGSTY 0.14.0 | PIGSTY 0.14.0 | N/A | N/A |
| u26.aarch64 | PIGSTY 0.14.0 | PIGSTY 0.14.0 | PIGSTY 0.14.0 | N/A | N/A |
Source
github.com/skuznetsov/pg_sorted_heap
pg_sorted_heap-0.14.0.tar.gz
Install
Make sure PGDG and PIGSTY repo available:
Install this extension with pig:
Config this extension to shared_preload_libraries:
Create this extension with:
Usage
Sources: pg_sorted_heap README, stable API, SQL API, control file.
pg_sorted_heap adds the sorted_heap table access method, per-page zone-map pruning, maintenance helpers, built-in svec/hsvec vector types, a planner-integrated sorted_hnsw index AM, and stable GraphRAG wrappers. Upstream documents PostgreSQL 16, 17, and 18 support for the current release surface.
Sorted Heap Tables
Use USING sorted_heap on tables with a primary key. Bulk loads are sorted by primary key on the COPY path, and compaction globally sorts existing rows while rebuilding the zone map:
The README describes planner-injected SortedHeapScan paths for primary-key predicates and zone-map pruning at the heap-block level.
Maintenance And Observability
Stable maintenance functions include:
Partition helpers operate on concrete sorted-heap leaves under a parent:
Vector Search
The stable vector API includes svec(dim) for float32 vectors, hsvec(dim) for float16 vectors, and the sorted_hnsw index AM:
For compact base-table storage, use hsvec and the matching operator class:
The shared decoded graph cache is controlled by sorted_hnsw.shared_cache. Upstream examples note that using it requires preloading the extension:
GraphRAG
The stable fact-shaped GraphRAG entry point expects facts clustered by (entity_id, relation_id, target_id) or a registered alias mapping:
Register alternate fact column names once:
For routed or tenant-sharded fact tables, use sorted_heap_graph_route(...) and inspect routing with sorted_heap_graph_route_plan(...).
Stable GUCs
sorted_heap.enable_scan_pruning: enable sorted-heap custom scan pruning; defaulton.sorted_heap.vacuum_rebuild_zonemap: rebuild zone maps duringVACUUM; defaultoff.sorted_heap.lazy_update: defer eager zone-map update maintenance; defaultoff.sorted_hnsw.ef_search: runtime HNSW search breadth; default64.sorted_hnsw.shared_cache: shared decoded graph cache when preloaded; defaulton.sorted_hnsw.sq8: SQ8 decoded cache representation; defaulton.sorted_hnsw.build_sq8: low-memory index build mode; defaultoff.
Caveats
sorted_heap.lazy_update = ontrades scan pruning for faster update-heavy workloads until compaction or merge restores pruning.sorted_hnsw.shared_cacheshould be used withshared_preload_libraries = 'pg_sorted_heap'.- Planner-integrated
sorted_hnswordered scans requireLIMIT; the SQL API says they are not chosen when there is no limit or whenLIMIT > sorted_hnsw.ef_search. - The lower-level GraphRAG and legacy/manual ANN helpers remain documented, but the stable application-facing API is the compact surface in
docs/api-stable.md.