SQL Query Logging
The SQL Log page shows the most recent queries received by the account database, with some context information for each.
The logging is enabled by default, and can be disabled and re-enabled on demand from the Logging Manager page. Disabling the logging removes all query log records.
The log shows a summary page similar to this. Some elements of each entry may be truncated for list display.
When errors occur, those are represented in the log.
Clicking on the 'expand display' link will expand the display for that query log record, to include the full query (with scroll bars, as required) and all arguments, as below:
The log is trimmed to under 100 queries, in the default configuration. You can override the monitor.cleanup_sql_log function to replace it with your own preferred trimming functionality. This is not a trigger, as we try to leave PL/pgSQL optional, and plain SQL functions cannot be triggers. It is, instead, a plain old SQL function called by the RdbHost runtime. If you remove it, the cleanup will just fail silently. Disabling and re-enabling logging will serve to restore the lost cleanup function.
The log table is called 'sqllog', and is kept in a schema called 'monitor' in your account database. You can use queries, either from RdbAdmin or from your choice of clients to manipulate the log entries or do statistics as you wish. You can even disable trimming and allow queries to accumulate forever. The log is in your account though, so it is billable space usage.
Log Entry Elements
The elements of each query entry in the log are listed and described here:
- The query is truncated to 1024 characters in the list view, and displayed complete in the popup view; The arguments are not interpolated for display, but are displayed separately
- The arguments are shown individually, complete if brief, truncated if not, and binary data is represented as the phrase 'BINARY'. The list view shows 3 or 4, and the complete view shows all.
- The time (GMT) that the query started. If the result is an error, the time will be the time of logging; an error causes the transaction to rollback, and rolling back loses the original timestamp insertion, as it was part of the transaction.
- This is 'OK' for successes, and an error message for errors. Any error message indicates the transaction failed, and no database change occurred. The list display changes for error results, to show more text.
- How many milliseconds query took to execute.
- The database role that executed the query (Super, Reader, Auth, Preauth, Global_reader).
- If the query was a keyword lookup, this is the keyword.
- The request-id submitted with the query (if any).
- Notices issued by PostgreSQL during the query.
- Notify messages emitted by NOTIFY statements during the query execution. These could be explicitly stated in the query, or in triggers invoked during execution.