What a PostgreSQL performance audit answers before you change settings
Most slow PostgreSQL systems respond to a tuning reflex: raise shared_buffers, add an index, lower random_page_cost, or copy a configuration from a blog post. Each change can help, and each can also make a different workload worse. The reader in this situation usually has one of three triggers: queries that have slowed down, CPU or disk I/O that keeps climbing without an obvious cause, or a major upgrade on the calendar and a fear that performance will shift under them. In all three cases, the first question is not which setting to change but which queries and resources are actually responsible. A performance audit starts there, so that every later change can be tied to a measured cost rather than a hunch.
An outside review gathers that evidence in one pass. It reads the current settings against the hardware and the workload, ranks the heaviest statements by total and mean time using pg_stat_statements, checks index usage and table and index bloat, and looks at how connections are opened, pooled and held. The output is a prioritized fix list. Each item names the symptom it addresses, the evidence behind it, the change proposed and the effect the reviewers expect, with the confidence level stated. Ask for that structure explicitly in the scope, and ask whether the expected effect will be checked by a before and after measurement on the same workload. A list without measurements is an opinion.
Tune in-house when the team already collects query statistics, can reproduce the slow workload in a test environment, and has someone who reads execution plans routinely. Commission an audit when the slow path is unclear, when the same database has been tuned several times without lasting results, when production data cannot be copied for testing, or when a major upgrade or a new application load creates a deadline. Confirm before you engage that pg_stat_statements is enabled or can be enabled on your version, that you can share query text and plans under your data handling rules, and that you have a window for benchmarking. Those three answers determine how much of the review can be done without disturbing production.
What a PostgreSQL performance audit checks, area by area
This table compares the six areas a PostgreSQL performance review covers: what the reviewer examines, the evidence to prepare, and the findings that usually lead to a change. Read each row as a checklist for your own environment, and use the last row to confirm that every finding ends in a prioritized fix with an expected effect.
| Audit area | What the reviewer examines | Evidence to prepare | Findings that usually lead to a change |
|---|---|---|---|
| Configuration | Server parameters compared with the workload, version and hardware, including memory, checkpoint, WAL and autovacuum settings | Current postgresql.conf and postgresql.auto.conf values, the PostgreSQL version, and any settings changed by hand or by an operator | Memory settings out of line with host RAM, checkpoints forced by size, autovacuum falling behind, or settings left at defaults after a migration |
| Hardware and host | CPU count, memory, storage type, filesystem, I/O latency and how the host shares resources with other services | Host specifications, storage type and mount options, I/O and CPU metrics over a representative period, and virtualization or container limits | Storage that cannot keep up with write volume, memory pressure or swapping, CPU saturation, or noisy neighbors on shared hosts |
| Top queries (pg_stat_statements) | Queries ranked by total time, mean time and call count, with the share of database time each one uses | pg_stat_statements enabled with the reset time known, a sample from peak hours, and the application code paths that issue each query | A few statements that account for most database time, repeated queries that could be batched, or queries that changed behavior after a deploy |
| Index and bloat analysis | Unused, duplicate and missing indexes, table and index bloat, and the plans that depend on them | Index definitions, index usage statistics since the last reset, table size history and the output of EXPLAIN ANALYZE for the top queries | Indexes never scanned, overlapping indexes that add write cost, bloated tables that vacuum has not reclaimed, or missing indexes behind sequential scans |
| Connection handling | Connection counts, idle and idle-in-transaction sessions, pool configuration and how applications open and reuse connections | Connection counts over time, application pool settings, any PgBouncer configuration, and the driver and framework in use | Connection storms after restarts, idle transactions holding locks, pools sized larger than the database can serve, or session features that conflict with pooling |
| Fix list and expected effect | Each finding ranked by its effect on the workload, the risk of the change and the effort to make it | Agreed priorities from the business owners, a test environment where changes can be measured, and a rollback plan for each change | A short list of changes with the measurement that will show whether each one worked, plus items to defer until after an upgrade or hardware change |
How evidence turns into a prioritized fix list
The review starts with read-only access and a baseline of the running server, then moves through query statistics, configuration and hardware, indexes and bloat, and connection handling. Each phase feeds the next, so a query that ranks high in pg_stat_statements is checked against its plan, its indexes and its connection pattern before anything is recommended. The reviewer hands over the ranked fix list with its expected effect and the evidence behind each item. Nothing changes until the client approves the items it wants applied. The final step is a retest that compares results with the baseline.
Review phases, with the client approval gate and evidence handover marked.
How the PostgreSQL performance audit runs from access to fix list
The audit moves from a written scope to read access, a captured baseline, evidence-based review of queries, settings and hosts, and finally a ranked backlog where each fix states its expected effect and how it will be verified.
Agree scope and change rules in writing
Before any access is granted, the client and DeployOpen agree in writing which databases, hosts and applications are in scope, which business periods the review must cover, and who may approve any change. The agreement also states that the audit is read-only: no settings, indexes or schema objects are changed during collection. The step closes when both parties have signed the scope and the named contacts for questions and access approvals are confirmed.
Grant read access and confirm statistics collection
The client's DBA or platform owner creates a read-only monitoring role and provides connection details for the primary, replicas and any pooler. DeployOpen checks whether pg_stat_statements is loaded and collecting. If it is not active, the client enables it through their normal change process, which usually requires a restart, so the team schedules that change before the baseline. The step closes when a test query against the extension returns rows and the client confirms when the statistics were last reset.
Capture a baseline during representative load
DeployOpen records the current settings, pg_stat_statements totals, table and index statistics, and host metrics over a window that includes normal peak activity. The team confirms the window covers a full normal business cycle, such as the close of a daily batch or a weekday peak, rather than a quiet period. Any incident, deployment or maintenance job during the window is logged so it can be excluded from conclusions. The step closes with a saved baseline snapshot and a short list of the events that happened during it.
Review top queries and their plans
The team ranks statements by total execution time, mean time and call count, then pulls execution plans for the top entries using EXPLAIN ANALYZE on a non-production copy or during an agreed low-risk window. Each query is tagged with its likely cause, such as a missing index, stale statistics, a poor join choice or application behavior like N+1 calls. The step closes when every top query in the backlog has a tagged cause and the team has noted which plans were measured and which were inferred.
Check settings, bloat and connection handling
DeployOpen compares the running configuration with the server version, workload and hardware, checking memory, checkpoint, autovacuum and connection settings. It also measures table and index bloat, unused indexes and connection counts, including whether a pooler is in use and how it is configured. Each finding is linked to evidence from the baseline rather than a generic recommendation. The step closes when every setting checked has either a documented reason to keep it or a proposed change with its supporting data.
Correlate host metrics and check for contention
The team reviews CPU, memory, disk latency, I/O wait and network metrics from the same baseline window, and checks wait events and lock activity in the database. This separates problems the database can fix from those caused by storage, virtualization or shared hosts. Where the client lacks host metrics, the audit records that gap as a limitation instead of assuming a cause. The step closes when each major slowdown has been matched to either a database or host explanation, or marked as unresolved with the data still needed.
Write the ranked fix list with expected effect
DeployOpen turns the findings into a backlog ranked by expected impact, risk and effort. Each item states the problem, the evidence, the proposed change, the expected effect as a qualitative estimate with its confidence level, the rollback path and how the result will be measured. The team also records which items need a test in a staging environment or a benchmark before go-live. The step closes when the client has the written list and has confirmed which items they will approve, schedule or decline.
Which audit scope fits your situation
When a single production database makes user-facing pages slow, the first priority is finding which statements consume the most time under real traffic. The review usually starts with query ranking, then checks whether connection handling or lock waits add latency before any setting is changed. Index and bloat analysis follows, because a missing index on a hot path often explains more than server configuration does.
- Top statements by total time: ranking from
pg_stat_statementsshows where the database spends its time, not which queries merely look expensive. - Connection behavior: counts of active, idle and idle-in-transaction sessions show whether the application opens too many connections.
- Plan changes: comparing current
EXPLAIN ANALYZEoutput with the query's history shows whether a statistics change or data growth shifted the plan. - Lock and wait events: long waits on locks or I/O can look like slow queries in page timings.
- Application timing: page-level traces let the reviewer match slow pages to specific statements.
Collect a stats snapshot during a slow period, the page list with timings, and the query log for the same window. A reviewer cannot judge whether a query is acceptable without knowing the expected response time, the peak request rate, or which pages users actually complain about.
A reporting database with long-running analytical queries shifts priority toward memory, parallel execution and the planner. Here the review checks whether sort and hash operations spill to disk, whether queries run in parallel when the hardware allows it, and whether statistics are accurate enough for large joins and aggregates. Index design matters, but indexes rarely fix a scan that is correctly reading a large share of a table.
- Memory and spill behavior: plans that write temporary files point to memory settings and query shape.
- Parallel query use: plans that stay serial on multi-core hosts often reflect limits or costs set too low.
- Planner estimates: large gaps between estimated and actual row counts usually drive the worst join choices.
- Refresh and load windows: reports that compete with loads or vacuum runs need separate scheduling.
- Replica use: whether reports run on a standby affects which settings matter and what the primary sees.
Collect representative report queries with their parameters, the run schedule, and the time window each report must finish within. A reviewer cannot tell which trade-off is right, such as memory per query against concurrency, without knowing how many reports run at once and what the business deadline is.
Before a planned major upgrade, the audit focuses on whether the current workload will behave the same on the target version. The review compares query performance between versions, checks planner statistics handling, and identifies settings or extensions that change across releases. Benchmarks become the central evidence, since the reviewer needs a before and after picture to set the upgrade method and rollback plan.
- Baseline capture: top statements and plan shapes recorded on the current version give a reference point.
- Target version behavior: the reviewer checks release notes for planner and I/O changes that could affect your queries.
- Statistics handling: whether planner statistics survive the upgrade method affects the post-upgrade warm-up period.
- Extension compatibility: extensions and their settings may need separate validation before cutover.
- Replay testing: representative workload replay on a copy shows regressions before production.
Collect the current version, the planned target version, the upgrade method under consideration, and a copy of production data or a representative subset. A reviewer cannot confirm that the copy matches production statistics or hardware without you providing the host specifications and data volume.
When performance dropped after a recent application or database release, the audit is a comparison exercise. The first step is establishing what changed: application code, schema, configuration, extensions, or the PostgreSQL minor or major version. Priority goes to the statements whose timing shifted, because those are the candidates for the regression.
- Before and after statements: comparing
pg_stat_statementssnapshots from both periods isolates the changed queries. - Plan diffs: the same query with a different plan points to statistics, indexes or settings that moved.
- Change timeline: a dated list of deployments, config edits and schema migrations lets the reviewer correlate events.
- Resource trends: CPU, I/O and connection counts across the change window show whether load or efficiency shifted.
- Rollback feasibility: checking whether a specific change can be reverted tests the hypothesis.
Collect stats snapshots or dumps from before and after the change, the deployment record, and the configuration files in use at each point. A reviewer cannot attribute a slowdown to a single change without the timeline and without knowing whether data volume grew during the same period.
Why pg_stat_statements comes before any setting change
Ranking queries by total and mean time shows where the database actually spends its effort before anyone touches a setting. Total time identifies the statements that consume the most server time across all calls, which is often a frequently run query that is individually fast. Mean time identifies the expensive individual executions, which may run rarely but block users when they do. An audit that starts with shared_buffers or work_mem without this ranking tends to move cost elsewhere: a larger memory setting can relieve one query while increasing memory pressure under concurrency, or a checkpoint change can shift I/O into a window where a different batch job suffers.
Statistics have limits that the reader should keep in view. The pg_stat_statements view reflects only the collection window since the last reset, so a snapshot taken right after a deployment or a restart may not represent the normal workload. Reset timing matters: if the statistics were cleared during an incident or a release, the ranking covers a different mix of traffic than the one users see at month end. Confirm when the view was last reset, which application releases ran in that window, and whether the extension's settings were enabled for the full period. The view also does not explain why a query is slow. It reports timing and buffer counters, not the plan the planner chose, so a high-ranked statement still needs its plan examined.
Plans are examined as a separate step, once a query has earned a place on the backlog. The PostgreSQL documentation on EXPLAIN is the reference for reading estimated and actual rows, and the sibling topics on finding slow queries with pg_stat_statements and on reading EXPLAIN ANALYZE cover the mechanics in detail. For the audit, the output to ask for is a short list of top statements with their call counts, mean and total time, and a plan for each one, so that every proposed fix can be traced back to a measured cost and a specific change in the plan.
Protecting data and access during a PostgreSQL performance audit
A performance review needs to see real queries, plans and configuration, which can expose customer rows, credentials and host access. The cards below set out the controls to agree before the review starts and who approves each one, so the audit stays inside the data and access your organization already allows.
Read-only roles that still expose rows
A read-only role stops writes, but it can still read every table it is granted, including customer rows that a tuning review does not need. Ask for a role limited to catalog views and statistics such as pg_stat_user_tables and pg_stat_statements, with SELECT denied on business tables. Where plans need table statistics, have the data owner confirm that row sampling is acceptable. Approval: the database owner and the data protection officer.
Sensitive literals in query text
pg_stat_statements normalizes queries, but the stored text can still carry personal or payment data in cases where literals are not replaced, such as dynamic SQL or statements run through some drivers. Before the reviewer reads the view, check a sample for names, card fragments, account numbers or identifiers, and restrict access to the view to the audit role. Redact any exported extract before it leaves the environment. Approval: the database owner, with the privacy or payments lead for scope.
Changes made directly on production
Tuning steps such as ALTER SYSTEM, new indexes or ANALYZE runs can change live behavior, and some index builds lock or consume I/O. Agree that the reviewer proposes changes only as written scripts, that they run first on a restored copy or staging system, and that production changes go through your normal change process with a rollback step. Approval: the platform owner and the change advisory board.
Credentials shared in tickets
Reviewers often ask for connection strings in a ticket or chat thread, and those values then persist in tool history and logs. Issue a named account per reviewer with an expiry date, deliver the password through your secrets manager, and rotate it when the review closes. Confirm that the password method in pg_hba.conf uses SCRAM rather than MD5. Approval: the identity or security team.
Evidence files with sensitive content
Findings usually include EXPLAIN output, slow query logs and host metrics, and these files can contain literal values, host names, IP addresses and internal paths. Store evidence in an approved location with access limited to the review team, strip literal values from plans before sharing, and set a deletion date in the agreement. Approval: the security team and the data owner, who confirm what may be retained.
Reviewer access to host systems
Database statistics rarely answer every question, and a reviewer may ask for shell access to read I/O, memory and kernel settings. Grant read-only access through a bastion with session recording, limit it to the commands the review needs, and keep the database server's administrative account out of the reviewer's hands. Approval: the infrastructure owner and the security operations lead.
What buyers ask before hiring outside PostgreSQL performance help
What drives the cost and effort of a PostgreSQL performance review?
The scope written before work starts sets most of the cost. The main drivers are the number of database clusters and databases, how many applications and query patterns touch them, the size and age of the workload history available for analysis, and whether the review covers only the database or also the hosts, storage and connection layers around it. Cost is paid for the reviewer's time: reviewing configuration and hardware, analyzing top queries and plans, checking indexes and bloat, examining connection handling, and writing the prioritized fix list with expected effect. These are mostly one-time costs. Ongoing tuning or retesting after fixes is a separate piece of work. Ask any provider for a quote that lists each cluster in scope, the data sources it will use, what is excluded, and whether a retest is included.
Can our own database team run a performance audit in-house?
Yes, many teams can, and the work is well documented. The PostgreSQL project publishes the configuration parameters, statistics views and extensions that a review relies on, and pg_stat_statements is the usual starting point for ranking slow queries. The harder parts are judging which findings matter for your workload, separating a query problem from a hardware or connection problem, and resisting changes that trade one symptom for another. An internal team usually needs time away from feature work, a second reviewer for changes, and a safe place to test. An outside review adds an independent view and a written backlog. Decide based on whether your team has done this kind of analysis on production systems before, and whether it has the time to do it without pressure from an incident.
What access and time does our team need to provide for a review?
The reviewer needs read access to the systems being reviewed and a named contact who can answer questions about the application. Typical requests include: a read-only database role with access to the statistics views, the server configuration file, pg_stat_statements output for a representative period, slow query logs if they exist, host metrics for CPU, memory, disk and network, and the connection pooler configuration. The reviewer also needs to know the workload calendar, such as batch windows and peak periods, and any change freeze. Your team should expect to answer questions, approve any test runs against non-production copies, and review the findings before the fix list is final. Confirm exact access requirements and data handling rules in writing before work starts, especially if production data is involved.
How long does a PostgreSQL performance review take?
Duration depends mainly on the number of database clusters, the number of databases and applications per cluster, and how complex the workload is. A single cluster with a small set of known query patterns takes far less analysis than a shared cluster serving many applications with ad hoc reporting. Other factors include how quickly access is granted, how much representative statistics history exists, and how many rounds of questions the application team needs to answer. The reliable way to get a figure is to ask for a written timeline tied to the agreed scope, with milestones for data collection, analysis, the draft findings and the final fix list. Be wary of any timeline quoted before the number of clusters and the workload type are known.
What does the fix list contain and how is it prioritized?
A useful fix list has one entry per finding, and each entry names the evidence behind it. Expect the following for each item:
- The observed problem, such as a high-total-time query, unused indexes, table bloat, or connection saturation, with the query ID or table name
- The proposed change, such as an index, a query rewrite, a parameter change, or a pooler setting
- The expected effect, described in terms the evidence supports, and how to measure it
- The risk of the change, rollback steps, and who owns it
Priority should follow the work the database does for users, not the number of warnings. Ask for the scoring method in writing so the ranking can be checked.
Does a performance review guarantee a speedup?
A review identifies what is slow, why it is slow based on the evidence collected, and what changes are likely to help. It does not promise a specific speedup, because the result depends on the application, the hardware, the data and changes made by your team. Some findings have a large measurable effect, while others only reduce risk. Ask providers to state the basis for each expected effect and how it will be tested, for example by comparing the same queries before and after a change on a copy of the workload. Benchmarking tools such as pgbench are useful for load testing, but they do not replace a test that mirrors your own queries.
What happens after the fixes are applied?
Most of the work after a review belongs to your team: applying changes in order, testing each one, and watching for side effects. Outside help can be scoped as a retest of the fixed items, a follow-up review after a major workload change, or ongoing support. Ask whether the engagement includes a retest, how results are compared against the baseline captured during the review, and who approves changes to production. Performance also changes with data growth and new application releases, so plan for periodic reviews of the top queries and the statistics views. Major version upgrades can change planner behavior, so the fix list should note which items need rechecking after an upgrade.
Limits to confirm before you commission the review
A performance review is only as useful as the environment it can see and change. Confirm the items below with your database owner, platform team and provider before you sign a scope, because each one shapes which findings are possible and how they can be verified.
Major version and support end date
Confirm which PostgreSQL major version runs in production and when its community support ends. Version choice changes which planner behavior, statistics handling and I/O options apply, and a fix list for a version near end of life may lead straight into an upgrade. Ask your database owner for the exact version string from SELECT version(); so the review targets the real release.
- Supported version to check
- 14
pg_stat_statements access
Ask whether the pg_stat_statements extension is installed, preloaded and readable by the reviewer's role. Without it, query ranking falls back to logs and guesswork. Managed providers often expose it with limits, so confirm the statistics window and whether anyone can reset it during the engagement.
A representative workload window
Confirm that a period of normal and peak traffic can be captured, such as a full business cycle with batch jobs, reports and autovacuum activity included. A review sampled only during a quiet weekend will miss the queries that cause the slowdowns people report. Ask who owns the monitoring data that covers that window and how long it is retained.
Connection pooling in front of the database
Find out whether applications connect directly or through PgBouncer or a similar pooler, and in which mode. Pooling changes which connection settings matter, can break session features and alters how the reviewer reads connection counts and wait times. Ask the application team for the pool configuration and the drivers in use.
PgBouncer siteManaged-service setting restrictions
If a cloud or hosted provider runs the database, confirm which parameters can be changed, which need a restart and whether the provider allows kernel or storage changes at all. Some recommended fixes will be impossible on that platform. Ask the provider for its documented parameter list and change process before the review starts.
A staging copy to test expected effects
Confirm whether a staging database with comparable data volume and hardware exists, and who can run workload replays against it. Each fix in the priority list should carry an expected effect that is measured before it reaches production. Ask your platform team who approves changes to staging and how long a test cycle can run.
How DeployOpen scopes, delivers and supports a PostgreSQL performance audit
DeployOpen treats a PostgreSQL performance audit as a fixed-scope piece of work with written deliverables. The review runs inside your own infrastructure, and the output is a prioritized fix list your team can act on, with optional retainer support afterward.
How we scope
- Agree in writing which PostgreSQL servers, databases, workloads and time windows the audit covers before any work starts.
- Confirm access to configuration files, pg_stat_statements data, and system metrics, and whether read-only or staging access is used.
- Define the deliverables, including the prioritized fix list with expected effect and the retest scope, so the quote follows from a clear scope.
How we build
- Review configuration and hardware settings against the workload, then rank top queries from pg_stat_statements by total and mean time.
- Analyze indexes, table and index bloat, and connection handling, and check each proposed change against plans and measured data.
- Test proposed fixes in a non-production environment where the client permits it, and record before and after measurements for each change.
How we hand over
- Deliver a written report that explains each finding, the evidence behind it, and the change proposed, ranked by priority and expected effect.
- Walk your database, operations and application teams through the findings so they can own the backlog after the engagement ends.
- Document the configuration changes, index and query recommendations, and the retest results in a form your change process can review.
How we support
- Retest agreed fixes after your team applies them and report whether the measured effect matched the expected effect in the fix list.
- Offer ongoing support, upgrades and continuous testing as a retainer if you want DeployOpen to keep reviewing performance after the audit.
- Confirm with DeployOpen the retest window, support hours and escalation path in the written scope before the engagement starts.

