How a report is made
pgloupe reads inputs and builds one report in stages. Each stage hands the next only what it needs.
logs ──► decoder ──► assembler ──► classifier ──► accumulators ──► report
▲
snapshots ──► delta (reset and eviction aware) ───────────┘
- Decoder. Reads stderr, csvlog or jsonlog, plain or compressed. For stderr it infers the
log_line_prefixfrom a sample and prints the one it chose; if no candidate matches nearly every line it says so and stops. Servers that log in Portuguese (Brazil), Spanish, French or German are read through a translation table (experimental). - Assembler. Joins continuation lines to their entry, per backend process, and attaches
DETAIL,HINT,CONTEXTandSTATEMENTlines to the entry they belong to. - Classifier. Turns each entry into an event: a statement with or without a duration, a lock wait, a temp file, a checkpoint, an autovacuum run, a connection, an error, and so on.
- Correlation. Connects a duration to the statement it belongs to when the server logged them apart (cursors, prepared statements, parse/bind/execute), and names the statement that held a lock another one waited for.
- Accumulators. Count and keep, per statement fingerprint, calls, time, percentiles, errors, lock waits and temp files. A fingerprint comes from the statement’s parse tree (
libpg_query), soWHERE id = 1andWHERE id = 2are one statement. - Join. If you gave snapshots,
pg_stat_statementscounts for the window are matched to the log’s statements by fingerprint. pgloupe notices resets, evictions and windows that do not overlap, and says so instead of showing a wrong number.pg_stat_databasefrom the same two snapshots gives the server’s load over the window. - Findings and advice. Rules turn the numbers into What to fix first and into Settings advice, each with the evidence behind it.
With a store (logs ingest), the accumulators’ per-hour results are kept in SQLite and a report for any window is built from them without decoding the logs again.
What it does not do
It reads files you give it or fetch with its own commands; it is not a monitoring system and it never changes your server. The only statements it runs are read-only queries against pg_stat_statements, pg_stat_database, pg_settings and a few catalog views.