PG-Strom

PG-Strom is an open-source extension module for PostgreSQL, designed for version 15 or later, that offloads SQL workload processing to GPU devices to accelerate data analytics and batch processing on large datasets.

Reviewed by 7wData

On this page

Publisher review

PG-Strom is an open-source extension module for PostgreSQL, designed for version 15 or later, that offloads SQL workload processing to GPU devices to accelerate data analytics and batch processing on large datasets. It targets users who need to run heavy analytical queries on PostgreSQL without migrating to a separate data warehouse, such as data engineers, analysts, and organizations dealing with big data. By leveraging GPU devices with thousands of cores per chip, PG-Strom aims to speed up operations like SCAN (WHERE-clause evaluation), JOIN, and GROUP BY, transparently replacing PostgreSQL's vanilla execution plans when GPU processing offers an advantage. The extension is developed by HeteroDB and distributed under the PostgreSQL License, with active community support through GitHub discussions and issue trackers.

PG-Strom's core technology includes an automatic GPU code generator that produces GPU programs directly from SQL commands, and an asynchronous parallel execution engine that runs these workloads on the GPU. A standout feature is GPUDirect SQL, which bypasses CPU and RAM to read data directly from NVMe SSDs or NVMe-oF storage to the GPU, maximizing bandwidth. Version 3.0 added support for NVIDIA GPUDirect Storage, enabling software-defined storage over NVMe-oF and shared filesystems. The extension offers two storage options: PostgreSQL's native heap storage for row-based data, and Apache Arrow files for efficient columnar data processing via a foreign data wrapper. Version 5.0 overhauled the architecture, switching from a multi-process to a multi-threaded model and replacing CUDA C++ native code with portable pseudo-code for better performance and stability. PG-Strom also supports execution of PostGIS functions and GiST index searches on the GPU, and includes a GPU cache for frequently updated table contents.

In the PostgreSQL extension ecosystem, PG-Strom occupies a unique niche by providing GPU acceleration, a capability not offered by standard extensions like pg_stat_statements or PostGIS. Compared to Cypher or TimescaleDB, which focus on graph or time-series workloads, PG-Strom targets general analytical SQL acceleration. Its main competition comes from proprietary solutions like BryteFlow or Amazon Redshift Spectrum, but PG-Strom is open source and integrates directly into PostgreSQL, avoiding data migration. The CMU Database Group's extension analysis notes PG-Strom uses extensibility types including Functions, Types, Index Access Methods, Storage Managers, Client Authentication, and Query Processing, with 81,381 lines of code and low duplication (0.46%). It supports PostgreSQL versions 15 and 16.

The honest trade-offs with PG-Strom are significant. It requires specific hardware: at least one NVIDIA GPU with compute capability 7.5 (Turing generation) or later, and for GPUDirect SQL, NVMe SSDs under the same PCIe root complex as the GPU. The software stack demands CUDA Toolkit 12.2 update1 or later, a supported Linux distribution (Red Hat Enterprise Linux or Rocky Linux 8.x/9.x/10.x), and for GPUDirect Storage, the nvidia-fs driver and Mellanox OFED. IOMMU must be disabled for GPU-Direct SQL, which can be a security or configuration concern. PG-Strom is limited to PostgreSQL, so users on other databases cannot benefit. Setup and tuning require technical expertise, and the extension's performance gains are workload-dependent—ideal for large analytical queries but not for simple transactional operations. The community is active but smaller than mainstream PostgreSQL extensions, and documentation is primarily in English with some Japanese support.

Get the AI & data signal, daily.

335k+ subscribers read this every morning. One email, both newsletters. Unsubscribe anytime.

How it works

  1. GPU-accelerated SQL execution

    Automatically generates GPU programs from SQL commands and runs SCAN, JOIN, and GROUP BY workloads on GPU devices with thousands of cores.

  2. GPUDirect SQL for NVMe

    Bypasses CPU and RAM to read data directly from NVMe SSDs or NVMe-oF storage to the GPU, maximizing storage bandwidth for SQL processing.

  3. Apache Arrow file support

    Directly reads Apache Arrow format files via a foreign data wrapper, enabling efficient columnar data import and query without data transformation.

  4. Multi-threaded execution engine

    Version 5.0 switched from multi-process to multi-threaded model, using portable pseudo-code instead of CUDA C++ native code for improved performance and stability.

  5. PostGIS and GiST on GPU

    Supports execution of PostGIS functions and GiST index searches on the GPU, enabling real-time spatial analysis with a GPU cache for frequently updated tables.

  6. Transparent query plan replacement

    Replaces PostgreSQL's vanilla execution plans with GPU-accelerated versions when beneficial, without requiring changes to SQL queries or application code.

  7. Asynchronous parallel execution

    Runs SQL workloads on GPU devices asynchronously and in parallel, allowing simultaneous processing of multiple query operations for large datasets.

Strengths and trade-offs

Strengths

  • Accelerates SQL workloads for data analytics and batch processing on large datasets, with specific support for SCAN, JOIN, and GROUP BY operations.
  • Supports direct data access from NVMe/NVMe-oF storage to GPU via GPUDirect SQL, eliminating CPU/RAM bottlenecks and maximizing storage bandwidth.
  • Eliminates unnecessary data importing tasks by directly reading Apache Arrow format files through a foreign data wrapper, reducing preprocessing overhead.
  • Automatically generates GPU programs from SQL commands, transparently replacing PostgreSQL query execution plans without manual intervention.

Trade-offs

  • Requires specific hardware including at least one NVIDIA GPU with compute capability 7.5 (Turing generation) or later and, for GPUDirect SQL, NVMe SSDs under the same PCIe root complex.
  • Needs CUDA Toolkit version 12.2 update1 or later and a supported Linux distribution (Red Hat Enterprise Linux or Rocky Linux 8.x/9.x/10.x), limiting deployment flexibility.
  • Limited to PostgreSQL version 15 or later, so users on older PostgreSQL versions or other database systems cannot use PG-Strom.
  • May require additional setup and configuration, including disabling IOMMU for GPU-Direct SQL and installing Mellanox OFED drivers for NVMe-oF support.

Pricing context

Open source under the PostgreSQL License, free to use, modify, and distribute.

Getting started with PG-Strom

  1. Install PG-Strom extension

    Download the PG-Strom source code from the official repository. Build and install the extension using make and make install commands, ensuring you have CUDA Toolkit 12.2 update1 or later and a supported Linux distribution.

  2. Configure PostgreSQL for GPU

    Add 'pg_strom' to the shared_preload_libraries parameter in postgresql.conf. Restart the PostgreSQL server to load the extension. Then connect to your database and run 'CREATE EXTENSION pg_strom;' to enable GPU acceleration.

  3. Set up GPU and storage

    Verify that your NVIDIA GPU has compute capability 7.5 or later. For GPUDirect SQL, ensure NVMe SSDs are under the same PCIe root complex as the GPU. Disable IOMMU if required, and install the nvidia-fs driver for NVMe-oF support.

  4. Load data for acceleration

    Import your data into PostgreSQL using standard INSERT or COPY commands. Alternatively, create a foreign table using the arrow_fdw wrapper to directly query Apache Arrow files without data transformation.

  5. Run analytical queries

    Execute your SQL analytical queries as usual. PG-Strom automatically replaces PostgreSQL's execution plans with GPU-accelerated versions for SCAN, JOIN, and GROUP BY operations when beneficial. Monitor performance using EXPLAIN ANALYZE.

Frequently Asked Questions

What is PG-Strom and how does it accelerate PostgreSQL?

PG-Strom is an open-source PostgreSQL extension that offloads SQL workloads like SCAN, JOIN, and GROUP BY to NVIDIA GPUs. It automatically generates GPU programs from SQL commands and runs them asynchronously, speeding up data analytics and batch processing on large datasets without migrating to a separate data warehouse.

What hardware and software do I need to run PG-Strom?

You need at least one NVIDIA GPU with compute capability 7.5 (Turing generation) or later, CUDA Toolkit 12.2 update1 or later, and a supported Linux distribution like Red Hat Enterprise Linux or Rocky Linux 8.x/9.x/10.x. For GPUDirect SQL, NVMe SSDs under the same PCIe root complex are required.

How does GPUDirect SQL improve performance in PG-Strom?

GPUDirect SQL bypasses the CPU and RAM to read data directly from NVMe SSDs or NVMe-oF storage to the GPU. This eliminates bottlenecks in the CPU and memory subsystem, maximizing storage bandwidth for SQL processing and significantly accelerating large analytical queries.

Can PG-Strom work with Apache Arrow files?

Yes, PG-Strom can directly read Apache Arrow format files via a foreign data wrapper. This enables efficient columnar data import and query without data transformation, reducing preprocessing overhead and allowing seamless integration with Arrow-based data pipelines.

What are the main differences between PG-Strom and other PostgreSQL extensions?

PG-Strom uniquely provides GPU acceleration for general analytical SQL, unlike extensions like pg_stat_statements or PostGIS. Compared to TimescaleDB or Cypher, which focus on time-series or graph workloads, PG-Strom targets heavy analytical queries. It is open source and integrates directly into PostgreSQL, avoiding data migration.

Is PG-Strom free to use and what are its limitations?

PG-Strom is open source under the PostgreSQL License, free to use, modify, and distribute. Limitations include requiring specific NVIDIA hardware and Linux distributions, being restricted to PostgreSQL version 15 or later, and needing technical expertise for setup. Performance gains are workload-dependent, best for large analytical queries.

Alternatives

How PG-Strom compares

Direct head-to-head against 2 competitors. Picked by 7wData.

This tool

PG-Strom

Pricing
Open source under the PostgreSQL License, free to use, modify, and distribute.
Target
PG-Strom is an open-source extension module for PostgreSQL, designed for version 15 or later, that offloads SQL workload processing to GPU devices to accelerate data
Strength
Accelerates SQL workloads for data analytics and batch processing on large datasets, with specific support for SCAN, JOIN, and GROUP BY operations.
Watch for
Requires specific hardware including at least one NVIDIA GPU with compute capability 7.5 (Turing generation) or later and, for GPUDirect SQL, NVMe SSDs under the same PCIe root complex.

Brytlyt

Pricing
Custom/Contact sales
Target
GPU-accelerated PostgreSQL analytics
Deployment
On-premises
Strength
Native GPU-accelerated PostgreSQL fork
Watch for
Smaller community and fewer integrations than PG-Strom

PG-Strom

Pricing
Open source (PostgreSQL License)
Target
GPU-accelerated PostgreSQL extension
Deployment
On-premises
Strength
Direct GPU SQL acceleration via CUDA
Watch for
Requires NVIDIA GPU and CUDA setup

User reviews

No user reviews yet. Be the first to write one.

Sources

Reporting on this tool draws on these publicly available sources.

  1. heterodb.github.io
  2. heterodb.github.io
  3. db.cs.cmu.edu
  4. github.com
  5. en.heterodb.com