Casecommons / pg_audit_log

Create a trigger-based audit log for PostgreSQL
MIT License
3 stars 2 forks source link

Disable triggers during migrations #5

Closed BrentWheeldon closed 9 years ago

BrentWheeldon commented 12 years ago

The audit log insertions slow AR migrations down a lot (>30mins to less than 10 seconds).

tmikoss commented 9 years ago

There's a PgAuditLog::Function::DISABLED_USER constant - setting current user to that should cause the trigger to exit immediately, maybe that helps.

amarshall commented 9 years ago

We’d prefer to never implicitly disable triggers for fear that auditing would be unknowingly turned off, posing increased risk. Instead you can use PgAuditLog::Triggers.without_triggers { do_stuff } to turn off triggers for a block (which essentially does what @tmikoss suggested under-the-hood).