NAME

DBIx::Fast::Profile::Pg - PostgreSQL profiling and diagnostics

SYNOPSIS

my $db = DBIx::Fast->new( dsn => 'postgres://user:pass@host/db' );

my $plan  = $db->profiler->explain_query('SELECT * FROM t WHERE id = ?', 1);
my $ts    = $db->profiler->get_table_stats('t');
my $is    = $db->profiler->get_index_stats('t');
my $stats = $db->profiler->get_stats;
my $conns = $db->profiler->get_current_connections;

DESCRIPTION

PostgreSQL implementation of DBIx::Fast::Profile::Base, built on the pg_stat_* statistics views and pg_class/pg_index catalogs. Where a MariaDB equivalent exists, result keys mirror DBIx::Fast::Profile::MariaDB so polymorphic callers work across drivers.

METHODS

explain_query ($sql, @params)

Runs EXPLAIN on the statement after validating it against the same allowlist strategy used by the MariaDB profile (DML/CTE heads only; no terminators, comments or dollar-quoting; rejects pg_read_file-style file access, pg_sleep/advisory-lock DoS and dblink under both string quoting modes). Returns the plan rows or undef when validation fails. Plain EXPLAIN never executes the statement.

get_table_stats ($table)

Row count estimate and on-disk sizes for a table in the current schema.

get_index_stats ($table)

Indexes with their columns, position and scan counts.

get_stats / print_stats

pg_stat_database counters for the current database plus the current backend's pg_stat_activity row.

get_current_connections / get_processes

Connection summary (total/active/sleeping) and per-backend process list for the current database.

get_slow_queries

Top statements by total execution time from pg_stat_statements; returns an empty arrayref when the extension is not installed.

AUTHOR

SeHarrys

LICENSE

This is free software under the Artistic License 2.0.