Comments (6)
True, pgaudit is the better choice but I wanted something more practical for Actions Auditing for my app, not a full fledged db auditing, and this extension was a big step towards that.
Anyway, for whomever is concerned I have added partitioning in my fork. This is a breaking change as you cannot add partitioning to an existing table, thus audit.record_version needs to be created from scratch. I guess you could rename the existing table and copy over the data.
The naming convention for the partitions is: audit.record_version_SCHEMA_TABLE_YEAR_MONTH e.g. audit.record_version_public_account_2023_8
but since partition pruning is enabled by default you only need to query audit.record_version.
Year-Month based sub-partitioning only works if you have pg_cron installed beforehand.
P.S. This isn't battle tested yet; I just forked it last night. Let me know if you need an update in a few months.
from supa_audit.
Can you suggest any optimized ways to partition this table
I haven't had experience with optimizing query performance at that scale yet, but ts
seems like the easy choice for partitioning. Im not clear how we'd allow user configurability, or provide useful defaults, for partitioning with the table as part of an extension but its a good question
I'll leave this open in case others have ideas
from supa_audit.
thanks
from supa_audit.
I agree this needs partitioning to become relevant for large projects. A good practice would be to partition by table and sub-partition by year & month.
Partition creation can be automated:
Partition by Table
- Alter audit.record_version table to support list partitions on table_oid
- Add a partition during audit.enable_tracking
Sub-partition by Year & Month
- Add a function that adds a partition to an existing audit.record_version_table_oid for the current month
- During audit.enable_tracking if pg_cron is installed run the function once for the current month and schedule to run using pg_cron at the first day of each month (0 0 1 * *)
Partition Naming Proposal
audit.record_version_table-oid_year_month
Example: audit.record_version_16328_2023_08
P.S. The sql code is very straight-forward but I haven't dealt with pg extensions before. I could really use a contributing guide.
from supa_audit.
this project is a convenient approach for maintain an audit history for low-mid volume tables for consumption within SQL. Past that use-case, we recommend logging based solutions that are more configurable like https://www.pgaudit.org
from supa_audit.
I'm going to close this issue as out-of-scope but you're welcome to continue the discussion to suggest partitioning strategies for e.g. forks or local use!
from supa_audit.
Related Issues (20)
- make install fails HOT 10
- Cloud version HOT 4
- Who made a given change HOT 2
- Make Install error with llvm
- How can I use this extension for foreign tables since primary key constraints are not supported on foreign tables . HOT 4
- Triggers should be `after`
- Record the `application_name` connection parameter HOT 1
- Enable auditing, but ignore specific columns HOT 1
- v0.2.0 make, cannot stat './/supa_audit--0.1.0.sql' HOT 7
- ERROR: function uuid_generate_v4() does not exist (SQLSTATE 42883) HOT 2
- How can we use this extension when primary key is already in UUID format? HOT 2
- Include user who made change (assuming a system where every user also has a postgres role) HOT 1
- Does not install on Supabase unless `extensions` schema on search_path HOT 1
- Fails on insert in a table when the inserted row is as a result of auth.users trigger HOT 1
- Error when selecting the "Server Error" filter on Auth audit logging HOT 1
- Audit table cannot be backed up HOT 2
- Applying extension via migrations not working for 0.3.1 HOT 1
- running 0.3.1 standalone SQL file throws error HOT 1
- Add supa_audit to extensions lib HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from supa_audit.