Halloween DealsAmazon USHalloween week deals: useful picks before month-endAmazon US: current deals, useful picks and tech finds.Check DealsSlow PC?RecommendedPC slow today? Run a repair scan before it gets worseResolve common Windows issues and optimize system performance.Scan NowHalloween DealsAmazon USOctober picks are moving - compare before checkoutAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk5 min

PostgreSQL Was at 30% CPU, but the App Was Still Down: How to Find the Bottleneck

PostgreSQL can show spare CPU while the app is stuck waiting elsewhere. Trace the failure through app symptoms, database waits, connection pools, and host metrics.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

An app can be unavailable while PostgreSQL shows only 30% CPU because CPU utilization measures how busy the processor is—not whether requests are waiting on connections, locks, storage, or another part of the application. The “30%” here is a scenario, not a verified incident measurement; without logs and monitoring data, it does not identify the cause.

Start with the user-facing failure, then compare its timing with PostgreSQL activity, connection and pool queues, and host metrics. That evidence can distinguish a database bottleneck from an application or dependency failure without treating low CPU as proof that the database is healthy.

As an Amazon Associate I earn from qualifying purchases.

What 30% PostgreSQL CPU does—and does not—tell you

CPU utilization is one signal, not an overall health score. A database can have spare CPU capacity while incoming work is stalled elsewhere: requests may be waiting for a database connection, a transaction may be blocked by a lock, storage operations may be slow, or the application may be failing before a query reaches PostgreSQL.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Nor does a database CPU chart necessarily describe the whole host or the app’s resource limits. Confirm what the metric measures, where it is collected, and its sampling window before interpreting it. PostgreSQL recommends pairing its own statistics with host tools such as top, iostat, and vmstat (PostgreSQL monitoring documentation).

Diagnose the failure from the app inward

1. Establish what users and services are experiencing

Record request latency, error rates, timeouts, and affected endpoints around the time of the failure. Check whether the app can reach other dependencies, such as a cache or an external service. If all routes fail, the issue may be broader than one database query; if only database-backed routes fail, that narrows the search but does not prove the database is the cause.

Keep timestamps aligned across application, pooler, database, and host monitoring. A single CPU snapshot can miss a brief spike or conceal a sustained queue.

2. Compare connection counts with PostgreSQL activity

Inspect pg_stat_activity during the affected period. PostgreSQL describes it this way: “The pg_stat_activity view will have one row per server process, showing information related to the current activity of that process.” Its state and wait-event columns help separate active work from time spent waiting (PostgreSQL activity statistics).

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

An active backend with a non-null wait event is not necessarily making progress on CPU; it is executing a query while waiting somewhere in the system. Use the wait-event category and other activity details to guide the next check. A high connection count alone is also not a diagnosis: compare it with the configured limit, application demand, and whether sessions are active, idle, or waiting.

3. If sessions are waiting on locks, find the blocker

Use pg_locks alongside activity data to inspect outstanding locks. Ungranted locks can indicate contention; identify the affected object and the blocking and waiting sessions before changing transaction behavior or timeouts. PostgreSQL’s lock-monitoring guidance explains how to inspect locks and find relations with ungranted locks (PostgreSQL lock monitoring).

Long-running transactions are worth investigating when they appear in the chain of blocked work. Do not terminate sessions or alter application behavior solely because a lock is visible: first determine which transaction is holding it and what work would be interrupted.

4. Check the actual connection cap and its usage

PostgreSQL’s max_connections setting limits concurrent database connections. PostgreSQL 18 documentation says the typical default is 100 connections, but deployments can use a different value. Raising the cap increases resource allocation, and the setting takes effect at server start; it is not an automatic fix for slow queries or blocked work (PostgreSQL 18 connection settings).

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Check the running server’s actual configuration and usage rather than assuming the documented typical default applies. Compare demand against the cap and available resources. If the limit is being reached, determine why connections are accumulating and whether pooling or application-side connection management is appropriate before increasing it.

5. If there is a pooler, inspect its queue too

A connection pool can limit how many server connections an application maintains, but it also introduces a place where clients may wait. Compare client connections, server connections, and pool wait time rather than looking only at PostgreSQL. PgBouncer documents separate client and server connection limits (PgBouncer configuration); Datadog documents a PgBouncer metric for time clients wait for server connections (Datadog PgBouncer integration).

Pooling can help manage connection demand; it does not make a lock wait or an inefficient query disappear. PgBouncer’s pooling modes also have compatibility trade-offs: in transaction pooling, the server connection is returned after each transaction, so some features that depend on a persistent session do not work as they would with session pooling. Check the application’s session requirements against the selected mode (PgBouncer feature compatibility).

6. Compare database evidence with host and query behavior

Look at host CPU, memory, and I/O alongside PostgreSQL statistics. A database may be waiting on storage even when CPU is available; host-level pressure can also affect the application and database differently. PostgreSQL recommends standard Unix monitoring tools alongside its statistics (PostgreSQL monitoring documentation).

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Once a particular slow query is identified, use EXPLAIN to examine its plan. Avoid treating query-plan investigation as a substitute for checking queues and waits: the failing request may not yet have reached the query stage.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Choose a remedy that matches the evidence

Application-side pooling or PgBouncer

If evidence points to excessive or poorly managed connections, application-side pooling or a dedicated pooler such as PgBouncer may help control server connection demand. The choice depends on deployment complexity, how many PostgreSQL server connections will actually be maintained, whether you can measure waiting clients, and whether the application relies on session features affected by the pool mode. Confirm the required behavior before changing modes; pooling is not a general cure for locks, slow SQL, or failures elsewhere in the app.

Monitoring instrumentation

Choose monitoring based on whether it exposes the signals needed to answer this incident’s questions: PostgreSQL activity and wait data, plus pooler queue time when a pooler is present. Also account for collection overhead, required privileges, hosting compatibility, and operating cost. Datadog documents PostgreSQL and PgBouncer integrations (Datadog PostgreSQL integration; Datadog PgBouncer integration), but their existence does not make that product necessary for every deployment.

Use timeouts carefully

PostgreSQL’s lock_timeout limits how long a statement waits to acquire a lock. The documentation cautions against setting it globally in postgresql.conf, where it would affect every session; decide whether and where to use it based on the application’s needs and the identified blocking behavior (PostgreSQL client connection defaults).

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Windows Errors? Fix Them Before They SpreadFree repair scan
Crashes, No Sound, or Screen Glitches?Free driver scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.