16 lines
476 B
SQL
16 lines
476 B
SQL
DELETE FROM audit_log
|
|
WHERE created_at < NOW() - INTERVAL '30 days';
|
|
|
|
CREATE INDEX IF NOT EXISTS idx_audit_log_created_at
|
|
ON audit_log(created_at DESC);
|
|
|
|
CREATE INDEX IF NOT EXISTS idx_audit_log_action_time
|
|
ON audit_log(action, created_at DESC);
|
|
|
|
CREATE INDEX IF NOT EXISTS idx_audit_log_actor_time
|
|
ON audit_log(actor_id, created_at DESC)
|
|
WHERE actor_id IS NOT NULL;
|
|
|
|
CREATE INDEX IF NOT EXISTS idx_audit_log_entity_time
|
|
ON audit_log(entity_type, entity_id, created_at DESC);
|