provsql
Overview
| ID | Extension | Bin | Lib | Load | Create | Trust | Reloc | Schema |
|---|---|---|---|---|---|---|---|---|
| 2900 | provsql | No | Yes | Yes | Yes | Yes | No | - |
| Related | uuid-ossp pgmemento ddl_historization table_log data_historization table_version pgaudit pgmnemo pgcontext vectorize |
|---|
Requires uuid-ossp and shared_preload_libraries=provsql; the control file marks the extension trusted and non-relocatable.
Version
| Type | Repo | Version | PG Ver | Package | Deps |
|---|---|---|---|---|---|
| EXT | PIGSTY | 1.12.0 | 1817161514 | provsql | uuid-ossp |
| RPM | PIGSTY | 1.12.0 | 1817161514 | provsql_$v | - |
| DEB | PIGSTY | 1.12.0 | 1817161514 | postgresql-$v-provsql | - |
Build
You can build the RPM / DEB packages for provsql using pig build:
Install
You can install provsql directly. First, make sure the PGDG and PIGSTY repositories are added and enabled:
Install the extension using pig or apt/yum/dnf:
Preload:
Create Extension:
Usage
Sources:
- ProvSQL 1.12.0 documentation
- ProvSQL 1.12.0 release
- ProvSQL 1.12.0 changelog
- ProvSQL 1.12.0 control file
- ProvSQL user documentation
provsql adds semiring provenance and uncertainty management to PostgreSQL. Upstream documents provenance tracking, semiring evaluation, probabilities, Shapley and Banzhaf values, where-provenance, update provenance, and temporal features.
Load and Track Provenance
The CASCADE form installs uuid-ossp automatically if needed. The getting-started guide says the preload step is mandatory because ProvSQL installs a planner hook.
The user docs also describe provenance mappings:
Probability and Influence
Assign probabilities to tuple tokens:
Compute influence scores:
The docs also describe shapley_all_vars and banzhaf_all_vars for computing scores for all input variables at once.
Built-in Semirings
Built-in semiring functions use a provenance token and a provenance mapping table:
Current docs include compiled wrappers for sr_how, sr_which, sr_tropical, sr_viterbi, sr_lukasiewicz, sr_minmax, and sr_maxmin. For PostgreSQL 14 and later they also include sr_temporal, sr_interval_num, and sr_interval_int over multirange values.
Advanced users can still define custom semirings and evaluate them with provenance_evaluate or aggregation_evaluate; upstream recommends the compiled semirings when one matches the needed algebra.
Extra Modes and Helpers
Session GUCs documented upstream include:
provsql.tool_search_path is used for external probability and visualization tools such as d4, c2d, dsharp, minic2d, weightmc, and graph-easy. provsql.last_eval_method stores the last chosen probability-evaluation method. provsql.aggtoken_text_as_uuid makes aggregate-token cells render as their provenance UUIDs; agg_token_value_text(token) can recover the display text for those aggregate tokens.
The user guide separately documents where-provenance helpers, update provenance, temporal helpers such as get_valid_time, timetravel, timeslice, history, and undo, circuit-inspection helpers circuit_subgraph(root, max_depth) and resolve_input(uuid), and setup_search_path() for preparing the helper search path.
Current Probability and Inference Surface
The recent releases materially expand SQL coverage and probability evaluation:
- subqueries outside
FROM, includingEXISTS,NOT EXISTS,IN,NOT IN,ANY,ALL, row-valuedIN, scalar subqueries, andARRAY(SELECT ...); LEFT,RIGHT, andFULLouter joins, plus correctedEXCEPTandEXCEPT ALLprovenance;- SQL-faithful
NULLhandling for aggregates and exactHAVINGaggregate probabilities forCOUNT,SUM,MIN,MAX, andAVG; - probability-method selection through the method catalog and cost chooser, with
karp-luby,stopping-rule,sieve,d-tree, andprobability_bounds; - exact bounded-treewidth recursive reachability, unsafe-UCQ joint-width compilation, Möbius inversion for safe UCQs, and absorptive provenance for cyclic recursion;
- conditional events and distributions through the
target | evidenceoperator and the whole-tuplegiven()/prefix form; - continuous and discrete
random_variablefamilies, including normal, gamma, log-normal, beta, Weibull, Pareto, inverse-gamma, inverse-Gaussian, logistic, Poisson, binomial, geometric, hypergeometric, and negative-binomial distributions; - hierarchical Bayesian models where distribution parameters are themselves random variables, with conjugate posterior updates when a closed form is available;
- maintained provenance mappings that remain correct as source data changes, plus SQL-conformant
NULLbehavior forNOT IN,EXCEPT, and nullable random variables.
For example, condition a continuous value on observed evidence and read the posterior expectation:
The agg_token type supports arithmetic, unary minus, and comparisons for probabilistic aggregate expressions. Use the official probability and continuous-distribution chapters to choose between exact, compiled, and sampling-based evaluation methods.
Notes
- Version 1.11.1 corrects aggregate-comparison provenance and makes empty
sum,min,max, and product groups return SQLNULL. It also changes the content-addressed token produced forcount(*); re-run queries that materialized those tokens when the old empty-input behavior matters. - Version 1.12.0 extends Möbius evaluation to self-joins, lets
sr_formularender all gate types with an optional mapping, and reportssq-rewrite,bounded-jw, andreachabilitythroughprovsql.last_eval_method. It also fixes DML rewrite cases and makes repeatedremove_provenance()calls safe. ALTER EXTENSION provsql UPDATEinstalls the SQL changes. Reconnect sessions that stayed open across the update because ProvSQL caches function OIDs per session.- The 1.12.0 control file sets
default_version = '1.12.0', requiresuuid-ossp, marks the extension trusted, and is not relocatable. - Upstream documentation says ProvSQL has been tested on PostgreSQL 10 through 18.
provsql.update_provenanceand the multirange semirings require PostgreSQL 14 or later.- Update-provenance tracking remains experimental; validate its storage and performance costs before enabling it broadly.
Was this page helpful?
Thanks—your feedback helps us improve this page.
What got in the way? (optional)