pg_strom
Overview
| Package | Version | Category | License | Language |
|---|---|---|---|---|
pg_strom | 6.1 | OLAP | PostgreSQL | C |
| ID | Extension | Bin | Lib | Load | Create | Trust | Reloc | Schema |
|---|---|---|---|---|---|---|---|---|
| 2530 | pg_strom | No | Yes | No | Yes | No | No | - |
| Related | pg_duckdb pg_mooncake pg_orca columnar citus pg_clickhouse storage_engine pg_hint_plan hypopg index_advisor |
|---|
RPM only: version 6.1 is available for PostgreSQL 15-18; PostgreSQL 14 remains on 3.5; no DEB package is available.
Version
Install
You can install pg_strom directly. First, make sure the PGDG repository is added and enabled:
Install the extension using pig or apt/yum/dnf:
Create Extension:
Usage
pg_strom: Big-data processing acceleration using GPU and NVME
PG-Strom is a PostgreSQL extension that offloads analytical SQL workloads to GPU processors. It automatically generates GPU code from SQL, accelerating scan, join, aggregation, and sort operations. Full documentation is available at https://heterodb.github.io/pg-strom/.
Documentation Index
| Topic | Description |
|---|---|
| Install | Prerequisites, CUDA setup, RPM/source installation |
| Basic Operations | GpuScan, GpuJoin, GpuPreAgg fundamentals |
| BRIN Index | BRIN index support for GPU table scans |
| Partitioning | Partition-wise GPU execution |
| PostGIS | GPU-accelerated PostGIS functions |
| GPU-Sort | GPU-accelerated sorting with bitonic sort |
| GPUDirect SQL | NVMe-to-GPU direct data transfer |
| Apache Arrow / Arrow_Fdw | Columnar Arrow file foreign data wrapper |
| GPU Cache | In-GPU-memory table caching |
| Pinned Inner Buffer | Retaining inner-table results on GPU |
| Data Types | GPU-supported data types (int1, float2, etc.) |
| Functions & Operators | GPU-executable functions and operators |
| SQL Objects | System views and utility functions |
| GUC Parameters | All configuration parameters |
| Troubleshooting | Diagnostics and common issues |
Prerequisites
PG-Strom requires an NVIDIA GPU (compute capability 7.5+ / Turing or later), CUDA Toolkit 12.2+, and PostgreSQL 15+.
It must be loaded via shared_preload_libraries.
GpuScan: GPU-Accelerated Table Scan
PG-Strom replaces sequential scans with GPU-parallel scans. WHERE clause filters
are compiled into GPU kernels and executed on the device. This appears as GpuScan
in EXPLAIN output.
GpuJoin: GPU-Accelerated Hash Join
Multi-table joins are offloaded as GPU hash joins. PG-Strom consolidates sequential scan-join-aggregate chains into a single GPU kernel to minimize CPU-GPU data transfer.
GpuPreAgg: GPU-Accelerated Aggregation
GROUP BY and aggregate functions (SUM, AVG, COUNT, MIN, MAX, STDDEV, etc.) are executed on the GPU. PG-Strom performs a preliminary aggregation on the device, then the CPU handles the final merge.
GPU-Sort
GPU-Sort uses a bitonic sorting algorithm for ORDER BY and window functions. It requires CPU fallback to be disabled so all data resides in GPU memory.
Arrow_Fdw: Apache Arrow Columnar Store
Arrow_Fdw maps Apache Arrow files as foreign tables, enabling GPU-accelerated queries on columnar data. Combined with GPUDirect SQL, data flows directly from NVMe storage to the GPU.
Export PostgreSQL data to Arrow format using the pg2arrow CLI tool:
GPU Cache
GPU Cache keeps a copy of a PostgreSQL table in GPU device memory for ultra-fast analytical queries on frequently updated data (suitable for tables up to ~10GB). Synchronization is log-based via a row-level trigger.
GPUDirect SQL
GPUDirect SQL enables peer-to-peer DMA transfers from NVMe-SSD storage directly to GPU memory, bypassing CPU and system RAM entirely. This is ideal for large analytical scans where the GPU filters data before the CPU sees it.
Requirements: NVMe-SSD storage, NVIDIA GPUDirect Storage support, nvidia-fs kernel module.
In EXPLAIN output, GPUDirect SQL appears as a note on the scan node indicating direct NVMe-to-GPU data transfer.
PostGIS GPU Acceleration
PG-Strom accelerates several PostGIS functions on the GPU, including
st_contains, st_crosses, st_relate, and st_makepoint.
GpuJoin can leverage GiST (R-Tree) indexes for spatial join acceleration.
Custom Data Types
PG-Strom provides additional data types optimized for GPU processing:
| Type | Size | Description |
|---|---|---|
int1 | 1 byte | 8-bit integer |
float2 | 2 bytes | Half-precision floating-point (IEEE 754) |
These types are especially useful for compact storage of large datasets where precision can be reduced to save memory and increase GPU throughput.
System Views and Functions
Key GUC Parameters
Feature toggles:
| Parameter | Default | Description |
|---|---|---|
pg_strom.enabled | on | Master switch for all PG-Strom features |
pg_strom.enable_gpuscan | on | Enable/disable GpuScan |
pg_strom.enable_gpujoin | on | Enable/disable GpuJoin |
pg_strom.enable_gpuhashjoin | on | Enable/disable GpuHashJoin |
pg_strom.enable_gpugistindex | on | Enable/disable GpuGiSTIndex join |
pg_strom.enable_gpupreagg | on | Enable/disable GpuPreAgg |
pg_strom.enable_gpusort | on | Enable/disable GPU-Sort |
pg_strom.enable_brin | on | Enable/disable BRIN index on GPU scans |
pg_strom.enable_gpucache | on | Enable/disable GPU Cache usage |
pg_strom.cpu_fallback | notice | CPU fallback behavior on GPU recheck errors |
Optimizer cost parameters:
| Parameter | Default | Description |
|---|---|---|
pg_strom.gpu_setup_cost | 100 * seq_page_cost | Startup cost for GPU device initialization |
pg_strom.gpu_tuple_cost | cpu_tuple_cost | Per-tuple CPU-GPU transfer cost |
pg_strom.gpu_operator_cost | cpu_operator_cost / 16 | Per-operator GPU execution cost |
GPUDirect SQL:
| Parameter | Default | Description |
|---|---|---|
pg_strom.gpudirect_enabled | on | Enable/disable GPUDirect SQL |
pg_strom.gpudirect_threshold | auto | Minimum table size to trigger GPUDirect SQL |
pg_strom.gpu_direct_seq_page_cost | seq_page_cost / 4 | Scan cost via GPUDirect SQL |
Arrow_Fdw:
| Parameter | Default | Description |
|---|---|---|
arrow_fdw.enabled | on | Enable/disable Arrow_Fdw |
arrow_fdw.metadata_cache_size | 512MB | Shared memory for Arrow metadata cache |
GPU memory management:
| Parameter | Default | Description |
|---|---|---|
pg_strom.gpu_mempool_segment_sz | 1GB | GPU memory pool segment size |
pg_strom.gpu_mempool_max_ratio | 50% | Max device memory for the pool |
pg_strom.gpu_mempool_min_ratio | 5% | Min preserved memory pool ratio |
pg_strom.cuda_visible_devices | (all) | Restrict to specific GPU device IDs |
Execution:
| Parameter | Default | Description |
|---|---|---|
pg_strom.max_async_tasks | 12 | Max concurrent GPU tasks per query |
pg_strom.enable_partitionwise_gpujoin | on | Push GpuJoin into partitions |
pg_strom.enable_partitionwise_gpupreagg | on | Push GpuPreAgg into partitions |
Was this page helpful?
Thanks—your feedback helps us improve this page.
What got in the way? (optional)