4 ms·
For a moment I thought Postgres had a mechanism to simplify doing this. I see this same "shadow table"+trigger pattern with other databases too.
by forinti 5y ago
For a moment I thought Postgres had a mechanism to simplify doing this.
I see this same "shadow table"+trigger pattern with other databases too.
- kmdupree 5y agoAh. Sorry to disappoint. The technique was just new to me, so I thought it was worth sharing. :)
- sharadov 5y agoYou can use pgaudit, it's an extension that let's you audit DDL/DML statements. It's a great auditing mechanism. I use it on all our prod postgres instances, but have only "DDL" enabled, because of the potential performance overhead https://github.com/pgaudit/pgaudit https://github.com/pgaudit/pgaudit
- AmericanChopper 5y ago> but have only "DML" enabled, because of the potential performance overhead Surely the amount of DDL statements would be trivial compared to the DML ones?
- sharadov 5y agoGood catch, I meant "DDL", corrected my comment.
- Scarbutt 5y agoThis extension simplifies things a bit: https://github.com/arkhipov/temporal_tables https://github.com/arkhipov/temporal_tables
- mdm12 5y agoIndeed. Better temporal support was added the ANSI SQL 11 standard[0] and it is supported by a number of databases, some (like Postgres) by extensions and others (like SQL Server) natively[1]. [0] https://en.wikipedia.org/wiki/SQL:2011 https://en.wikipedia.org/wiki/SQL:2011 [1] https://docs.microsoft.com/en-us/sql/relational-databases/tables/temporal-tables?view=sql-server-ver15 https://docs.microsoft.com/en-us/sql/relational-databases/ta...