pg_gftr
pg_gftr · Experimental CUDA sort-based grouped aggregation for integer columns
Overview
| ID | Extension | Package | Version | Category | License | Language |
|---|---|---|---|---|---|---|
| 102272 | pg_gftr | pg_gftr | 0.1.0 | OLAP | PostgreSQL | C |
PostgreSQL · 18
Usage
Sources:
pg_gftr 0.1.0 is an experimental PostgreSQL 18 extension for CUDA sort-based grouped aggregation. GPU execution needs an NVIDIA GPU, compatible driver and a CUDA-enabled build using CUDA Toolkit 12.2 or later. A separate CPU backend is a correctness reference. No PostgreSQL core patch is required.
Core Workflow
Install and load as a superuser, then explicitly enable the planner path:
Eligible plans can use Custom Scan (GftrAggregate). PostgreSQL performs the child scan, filtering and any CPU joins; the extension aggregates the resulting rows. It supports one plain integer grouping column and the shown built-in integer aggregates, including null keys and payloads.
Controls
| Setting | Default | Purpose |
|---|---|---|
pg_gftr.enabled | off | Offer custom aggregation paths |
pg_gftr.force | off | Give eligible paths an artificially low cost for experiments |
pg_gftr.backend | cuda | Choose CUDA or the explicit CPU reference |
pg_gftr.mode | gftr | Select GFTR or GFUR CUDA aggregation |
pg_gftr.device | 0 | Device ordinal within the visible GPU set |
pg_gftr.min_rows | 100000 | Estimated input threshold unless forced |
pg_gftr.max_input_mb | 256 | Packed input limit in MiB |
pg_gftr.max_device_mb | 4096 | Per-operator device allocation limit in MiB |
pg_gftr.setup_cost | 1000 | Provisional setup cost |
pg_gftr.tuple_cost | 0.02 | Provisional per-row cost |
The cost model is not calibrated for every GPU. Reprepare cached statements after changing planner controls. CUDA_VISIBLE_DEVICES restricts the available device set. CUDA failures are reported as query errors; there is no automatic CPU fallback.
Session and Resource Boundaries
The installation script loads the hook in its creating session. Each new session must load the library, call its version function, or use administrator-configured preloading. Session loading needs no server restart. Simply installing SQL objects does not activate other sessions, and the planner path remains disabled until enabled.
The entire input is buffered. Host results, sort workspaces and PostgreSQL child-plan memory are additional to the input limit. Device scratch space counts toward the device limit, also capped at 90% of currently free GPU memory; concurrent sessions have no coordinated reservation. There is no disk spill, partial/final aggregation or multi-GPU execution. Exceeding capacity fails the statement without partial results. An in-flight GPU operation is not immediately interruptible.
Multiple grouping keys, expression keys, non-integer payloads, global aggregation, distinct or filtered aggregates, grouping sets and window queries are outside this version; unsupported shapes keep native paths. Upstream records GPU correctness checks on RTX A6000 and CPU checks on macOS; A100 execution remains untested in that record. Treat this as a research implementation and measure the whole SQL query, including data transfer.