September 24, 2026: PostgreSQL 19 Beta 4 Released!
Supported Versions: Current (18) / 17 / 16 / 15 / 14
Development Versions: 19 / devel
Unsupported versions: 13 / 12 / 11 / 10 / 9.6 / 9.5 / 9.4 / 9.3 / 9.2 / 9.1 / 9.0 / 8.4 / 8.3 / 8.2
This documentation is for an unsupported version of PostgreSQL.
You may want to view the same page for the current version, or one of the other supported versions listed above instead.

28.5. Dynamic Tracing

PostgreSQL provides facilities to support dynamic tracing of the database server. This allows an external utility to be called at specific points in the code and thereby trace execution.

A number of probes or trace points are already inserted into the source code. These probes are intended to be used by database developers and administrators. By default the probes are not compiled into PostgreSQL; the user needs to explicitly tell the configure script to make the probes available.

Currently, the DTrace utility is supported, which, at the time of this writing, is available on Solaris, macOS, FreeBSD, NetBSD, and Oracle Linux. The SystemTap project for Linux provides a DTrace equivalent and can also be used. Supporting other dynamic tracing utilities is theoretically possible by changing the definitions for the macros in src/include/utils/probes.h.

28.5.1. Compiling for Dynamic Tracing

By default, probes are not available, so you will need to explicitly tell the configure script to make the probes available in PostgreSQL. To include DTrace support specify --enable-dtrace to configure. See Section 16.4 for further information.

28.5.2. Built-in Probes

A number of standard probes are provided in the source code, as shown in Table 28.23; Table 28.24 shows the types used in the probes. More probes can certainly be added to enhance PostgreSQL's observability.

Table 28.23. Built-in DTrace Probes

Name Parameters Description
transaction-start (LocalTransactionId) Probe that fires at the start of a new transaction. arg0 is the transaction ID.
transaction-commit (LocalTransactionId) Probe that fires when a transaction completes successfully. arg0 is the transaction ID.
transaction-abort (LocalTransactionId) Probe that fires when a transaction completes unsuccessfully. arg0 is the transaction ID.
query-start (const char *) Probe that fires when the processing of a query is started. arg0 is the query string.
query-done (const char *) Probe that fires when the processing of a query is complete. arg0 is the query string.
query-parse-start (const char *) Probe that fires when the parsing of a query is started. arg0 is the query string.
query-parse-done (const char *) Probe that fires when the parsing of a query is complete. arg0 is the query string.
query-rewrite-start (const char *) Probe that fires when the rewriting of a query is started. arg0 is the query string.
query-rewrite-done (const char *) Probe that fires when the rewriting of a query is complete. arg0 is the query string.
query-plan-start () Probe that fires when the planning of a query is started.
query-plan-done () Probe that fires when the planning of a query is complete.
query-execute-start () Probe that fires when the execution of a query is started.
query-execute-done () Probe that fires when the execution of a query is complete.
statement-status (const char *) Probe that fires anytime the server process updates its pg_stat_activity.status. arg0 is the new status string.
checkpoint-start (int) Probe that fires when a checkpoint is started. arg0 holds the bitwise flags used to distinguish different checkpoint types, such as shutdown, immediate or force.