data_historization
data_historization
data_historization : PLPGSQL Script to historize data in partitionned table
Overview
| ID | Extension | Package | Version | Category | License | Language |
|---|---|---|---|---|---|---|
| 4320 | data_historization | data_historization | 1.1.0 | UTIL | PostgreSQL | SQL |
| Attribute | Has Binary | Has Library | Need Load | Has DDL | Relocatable | Trusted |
|---|---|---|---|---|---|---|
----dt- | No | No | No | Yes | no | yes |
| Relationships | |
|---|---|
| Requires | plpgsql |
| See Also | ddl_historization temporal_tables table_version gzip bzip zstd http pg_net |
Packages
| Type | Repo | Version | PG Major Compatibility | Package Pattern | Dependencies |
|---|---|---|---|---|---|
| EXT | PIGSTY | 1.1.0 | 18 17 16 15 14 | data_historization | plpgsql |
| RPM | PIGSTY | 1.1.0 | 18 17 16 15 14 | data_historization_$v | - |
| DEB | PIGSTY | 1.1.0 | 18 17 16 15 14 | postgresql-$v-data-historization | - |
| Linux / PG | PG18 | PG17 | PG16 | PG15 | PG14 |
|---|---|---|---|---|---|
el8.x86_64 | PIGSTY 1.1.0 | PIGSTY 1.1.0 | PIGSTY 1.1.0 | PIGSTY 1.1.0 | PIGSTY 1.1.0 |
el8.aarch64 | PIGSTY 1.1.0 | PIGSTY 1.1.0 | PIGSTY 1.1.0 | PIGSTY 1.1.0 | PIGSTY 1.1.0 |
el9.x86_64 | PIGSTY 1.1.0 | PIGSTY 1.1.0 | PIGSTY 1.1.0 | PIGSTY 1.1.0 | PIGSTY 1.1.0 |
el9.aarch64 | PIGSTY 1.1.0 | PIGSTY 1.1.0 | PIGSTY 1.1.0 | PIGSTY 1.1.0 | PIGSTY 1.1.0 |
el10.x86_64 | PIGSTY 1.1.0 | PIGSTY 1.1.0 | PIGSTY 1.1.0 | PIGSTY 1.1.0 | PIGSTY 1.1.0 |
el10.aarch64 | PIGSTY 1.1.0 | PIGSTY 1.1.0 | PIGSTY 1.1.0 | PIGSTY 1.1.0 | PIGSTY 1.1.0 |
d12.x86_64 | PIGSTY 1.1.0 | PIGSTY 1.1.0 | PIGSTY 1.1.0 | PIGSTY 1.1.0 | PIGSTY 1.1.0 |
d12.aarch64 | PIGSTY 1.1.0 | PIGSTY 1.1.0 | PIGSTY 1.1.0 | PIGSTY 1.1.0 | PIGSTY 1.1.0 |
d13.x86_64 | PIGSTY 1.1.0 | PIGSTY 1.1.0 | PIGSTY 1.1.0 | PIGSTY 1.1.0 | PIGSTY 1.1.0 |
d13.aarch64 | PIGSTY 1.1.0 | PIGSTY 1.1.0 | PIGSTY 1.1.0 | PIGSTY 1.1.0 | PIGSTY 1.1.0 |
u22.x86_64 | PIGSTY 1.1.0 | PIGSTY 1.1.0 | PIGSTY 1.1.0 | PIGSTY 1.1.0 | PIGSTY 1.1.0 |
u22.aarch64 | PIGSTY 1.1.0 | PIGSTY 1.1.0 | PIGSTY 1.1.0 | PIGSTY 1.1.0 | PIGSTY 1.1.0 |
u24.x86_64 | PIGSTY 1.1.0 | PIGSTY 1.1.0 | PIGSTY 1.1.0 | PIGSTY 1.1.0 | PIGSTY 1.1.0 |
u24.aarch64 | PIGSTY 1.1.0 | PIGSTY 1.1.0 | PIGSTY 1.1.0 | PIGSTY 1.1.0 | PIGSTY 1.1.0 |
Source
pig build pkg data_historization; # build rpm/debInstall
Make sure PGDG and PIGSTY repo available:
pig repo add pgsql -u # add both repo and update cacheInstall this extension with pig:
pig install data_historization; # install via package name, for the active PG version
pig install data_historization -v 18; # install for PG 18
pig install data_historization -v 17; # install for PG 17
pig install data_historization -v 16; # install for PG 16
pig install data_historization -v 15; # install for PG 15
pig install data_historization -v 14; # install for PG 14Create this extension with:
CREATE EXTENSION data_historization CASCADE; -- requires plpgsqlUsage
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'
);Last updated on