data_historization
Overview
| Package | Version | Category | License | Language |
|---|---|---|---|---|
data_historization | 1.1.0 | UTIL | PostgreSQL | SQL |
| ID | Extension | Bin | Lib | Load | Create | Trust | Reloc | Schema |
|---|---|---|---|---|---|---|---|---|
| 4320 | data_historization | No | No | No | Yes | Yes | No | - |
| Related | plpgsql ddl_historization temporal_tables table_version gzip bzip zstd http pg_net |
|---|
Version
| Type | Repo | Version | PG Ver | Package | Deps |
|---|---|---|---|---|---|
| EXT | PIGSTY | 1.1.0 | 1817161514 | data_historization | plpgsql |
| RPM | PIGSTY | 1.1.0 | 1817161514 | data_historization_$v | - |
| DEB | PIGSTY | 1.1.0 | 1817161514 | postgresql-$v-data-historization | - |
Build
You can build the RPM / DEB packages for data_historization using pig build:
pig build pkg data_historization # build RPM / DEB packages
Install
You can install data_historization directly. First, make sure the PGDG and PIGSTY repositories are added and enabled:
pig repo add pgsql -u # Add repo and update cache
Install the extension using pig or apt/yum/dnf:
pig install data_historization; # Install for current active PG version
pig ext install -y data_historization -v 18 # PG 18
pig ext install -y data_historization -v 17 # PG 17
pig ext install -y data_historization -v 16 # PG 16
pig ext install -y data_historization -v 15 # PG 15
pig ext install -y data_historization -v 14 # PG 14
dnf install -y data_historization_18 # PG 18
dnf install -y data_historization_17 # PG 17
dnf install -y data_historization_16 # PG 16
dnf install -y data_historization_15 # PG 15
dnf install -y data_historization_14 # PG 14
apt install -y postgresql-18-data-historization # PG 18
apt install -y postgresql-17-data-historization # PG 17
apt install -y postgresql-16-data-historization # PG 16
apt install -y postgresql-15-data-historization # PG 15
apt install -y postgresql-14-data-historization # PG 14
Create Extension:
CREATE EXTENSION data_historization CASCADE; -- requires: plpgsql
Usage
data_historization: Track data changes in partitioned log tables
PL/pgSQL scripts to historize data changes into partitioned tables.
Initialize Historization
Set up the necessary objects for a table (no data collected yet):
SELECT historize_table_init('public', 'my_table');
Start Historization
Install triggers to begin collecting changes into the _log table:
SELECT historize_table_start('public', 'my_table');
Stop Historization
Remove triggers and stop collecting changes:
SELECT historize_table_stop('public', 'my_table');
Reset Historization
Remove cron entries and columns created on the source table:
SELECT historize_table_reset('public', 'my_table');
Clean Historization
Remove the log table entirely:
SELECT historize_table_clean('public', 'my_table');
Partition Management
Create and drop partitions manually:
SELECT historize_create_partition('public', 'my_table_log', 0);
SELECT historize_drop_partition('public', 'my_table_log', 0);
Automate with pg_cron:
SELECT cron.schedule_in_database(
'create-partitions', '00 08 * * *',
$$SELECT historize_create_partition('my_table', generate_series(1, 4))$$,
'my_database'
);
Feedback
Was this page helpful?
Thanks for the feedback! Please let us know how we can improve.
Sorry to hear that. Please let us know how we can improve.