pmpp
pmpp · Run manually partitioned SQL work in parallel over asynchronous libpq connections and combine the results
Overview
| ID | Extension | Package | Version | Category | License | Language |
|---|---|---|---|---|---|---|
| 100700 | pmpp | pmpp | 1.2.3 | OLAP | PostgreSQL | C |
PostgreSQL · 10
Usage
Sources:
- Official PGXN distribution page
- Official README
- Official function documentation
- Official extension control file
pmpp 1.2.3, Poor Man’s Parallel Processing, runs manually partitioned SQL statements over multiple asynchronous libpq connections and streams compatible rows back into one PostgreSQL query. Use it when you can split work into independent statements yourself; it is not an optimizer-driven parallel-query engine or a distributed transaction manager.
Core Workflow
pmpp.distribute needs a local composite type that describes every returned row. A temporary table can supply that type without storing results. Pass an explicit worker count when the target server does not also have pmpp installed.
Installation creates the role pmpp. Grant that role only to users who are allowed to open the configured remote connections and execute the submitted SQL.
Main Interfaces
pmpp.distribute(row_type, connection, sql_list, cpu_multiplier, num_workers, setup_commands, result_format)handles one target and returnsSETOFthe supplied row type.pmpp.distributeoverloads acceptquery_manifest[],json, orjsonbfor multiple targets, with typed andrecordreturn variants.pmpp.metaruns commands such as DDL in parallel and reports each command’s result.pmpp.broadcastruns one row-returning query across a list of connections.pmpp.num_cpus()reports the server CPU count used by automatic worker sizing.
The connection argument may be a libpq connection string or a foreign-server name. A postgres_fdw server plus user mapping keeps credentials out of each function call, although the credentials still exist in PostgreSQL metadata.
Concurrency, Transactions, and Privileges
Each worker is a separate database session. It uses the remote user’s privileges and cannot see uncommitted changes in the caller’s transaction. Returned row order follows worker completion and is not deterministic unless the outer query sorts it.
If one subquery fails, pmpp attempts to cancel the others, but separate sessions do not provide atomic distributed commit or rollback. Do not use independent DDL/DML tasks as though they were one transaction; design idempotency and recovery explicitly. setup_commands and pmpp.meta can execute arbitrary SQL on worker sessions, so restrict the pmpp role, server mappings, and accepted query text.
Worker counts translate directly into additional connections and can overload the local or remote server. Set num_workers deliberately, account for connection limits and per-query resource use, and benchmark the complete workload. The upstream project targets PostgreSQL 9.4-era features and was last updated in 2018, so verify build and runtime behavior on the exact target release.