Documentation ¶
Overview ¶
Package postgresql contains code for parsing PostgreSQL slow query logs.
The Postgres slow query format ------------------------------
In general, Postgres logs consist of a prefix, a level, and a message:
2017-11-06 19:20:32 UTC [11534-2] LOG: autovacuum launcher shutting down |<-------------prefix----------->|level|<----------message-------------->|
2017-11-07 01:43:39 UTC [3542-7] postgres@test LOG: duration: 15.577 ms statement: SELECT * FROM test; |<-------------prefix------------------------>|level|<-------------------message---------------------->|
The format of the configuration prefix is configurable as `log_line_prefix` in postgresql.conf using the following format specifiers:
%a = application name %u = user name %d = database name %r = remote host and port %h = remote host %p = process ID %t = timestamp without milliseconds %m = timestamp with milliseconds %i = command tag %e = SQL state %c = session ID %l = session line number %s = session start timestamp %v = virtual transaction ID %x = transaction ID (0 if none) %q = stop here in non-session processes %% = '%'
For example, the prefix format for the lines above is: %t [%p-%l] %q%u@%d We currently require users to pass the prefix format as a parser option.
Slow query logs specifically have the following format: 2017-11-07 01:43:39 UTC [3542-7] postgres@test LOG: duration: 15.577 ms statement: SELECT * FROM test; |<-------------prefix------------------------>|<----------header-------------------->|<-----query----->|
For convenience, we call everything after the prefix but before the actual query string the "header".
The query may span multiple lines; continuations are indented. For example:
2017-11-07 01:43:39 UTC [3542-7] postgres@test LOG: duration: 15.577 ms statement: SELECT * FROM test
WHERE id=1;
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.