From: harunkucuk5 (@harunkucuk5) <noreply+harunkucuk5@github.com>
To: pgaudit/pgaudit <noreply+pgaudit-pgaudit@github.com>
Subject: [pgaudit/pgaudit] issue #300: Severe performance degradation when enabling pgaudit (ddl,role only) under high insert load
Date: Wed, 14 Jan 2026 09:32:45 +0000
Message-ID: <gh-pgaudit-pgaudit-300@github.com> (raw)
We are running a very high–throughput PostgreSQL workload (≈ 1M inserts/sec) using TimescaleDB.
Under normal conditions (pgaudit disabled), the system sustains this throughput without issues.
However, when pgaudit is enabled—even with logging limited strictly to ddl,role (no read/write auditing)—we observe a severe performance degradation, with throughput dropping to around 250K inserts/sec.
In addition to the performance drop, the following errors repeatedly appear in the logs:
```bash
Jan 12 13:44:31 DB-SQL2 patroni[1837773]: 2026-01-12 12:44:31.084 GMT [1837773] postgres@mydb ERROR: pgaudit stack is empty
Jan 12 13:44:31 DB-SQL2 patroni[1837777]: 2026-01-12 12:44:31.084 GMT [1837777] postgres@mydb ERROR: pgaudit stack is empty
Jan 12 13:44:31 DB-SQL2 patroni[1837769]: 2026-01-12 12:44:31.098 GMT [1837769] postgres@mydb ERROR: pgaudit stack is empty
Jan 12 13:44:31 DB-SQL2 patroni[1837771]: 2026-01-12 12:44:31.111 GMT [1837771] postgres@mydb ERROR: pgaudit stack is empty
Jan 12 13:44:31 DB-SQL2 patroni[1834099]: 2026-01-12 12:44:31.112 GMT [1834099] LOG: parameter "pgaudit.log" changed to "none"
```
### Workload details
Inserts are performed using the COPY command.
Data is ingested batch by batch (no single-row inserts).
No application-level DDL changes are happening during ingestion.
The following graph shows database throughput when auditing is enabled and then disabled again:
<img width="1838" height="795" alt="Image" src="https://github.com/user-attachments/assets/dcb2ce57-e119-482b-b8d9-8afb3b8f404a"; />
### Questions
Is this level of performance degradation expected when enabling pgaudit, even when only ddl,role logging is configured?
Are there any pgaudit configuration parameters or PostgreSQL settings that can mitigate this issue?
Does the pgaudit stack is empty error indicate a known bug or unsupported interaction (e.g., with COPY, TimescaleDB, or high concurrency workloads)?
Are there recommended best practices for using pgaudit in very high-ingest-rate environments?
Any guidance or insight would be greatly appreciated.