Skip to content

pgtrace

Event-driven query, lock, failure, and latency observability from PostgreSQL executor hooks.

pgtrace · Event-driven query, lock, failure, and latency observability from PostgreSQL executor hooks.

Overview

IDExtensionPackageVersionCategoryLicenseLanguage
101948pgtracepgtrace0.3STATMITC

PostgreSQL · 15, 16

Usage

Sources:

pgtrace Event-driven query, lock, failure, and latency observability from PostgreSQL executor hooks.

Enablement

Merge pgtrace into the existing preload list, restart PostgreSQL, and then create pgtrace in each database that needs its SQL objects:

shared_preload_libraries = 'pgtrace'
CREATE EXTENSION pgtrace;

Core Workflow

The following example is taken from the reviewed upstream documentation. Adapt object names, paths, credentials, and workload values before use.

-- Get count of currently tracked queries
SELECT pgtrace_query_count();

-- Clear all query stats
SELECT pgtrace_reset();

Main Objects

The reviewed install surface includes these prominent objects:

ObjectKindOperational role
pgtrace_query_statsVIEWInspection or query view created by the extension.
pgtrace_alien_queriesVIEWInspection or query view created by the extension.
pgtrace_failing_queriesVIEWInspection or query view created by the extension.
pgtrace_latency_histogramVIEWInspection or query view created by the extension.
pgtrace_metricsVIEWInspection or query view created by the extension.
pgtrace_query_countFUNCTIONCallable function from the reviewed install surface.
pgtrace_resetFUNCTIONCallable function from the reviewed install surface.
pgtrace_slow_queriesVIEWInspection or query view created by the extension.

Operations and Boundaries

  • The verified PostgreSQL-major evidence covers 15, 16; do not infer unlisted majors.
  • Preloading pgtrace changes cluster startup state; stage configuration and restart changes separately from CREATE EXTENSION.

Table reader