The first thing I could reproduce was a 504 Gateway Timeout. That was more useful than the original report that the site was unavailable: a gateway had accepted the request and stopped waiting for an upstream response.
I followed that wait through NGINX, the Kubernetes-hosted WordPress workload and PHP-FPM. The database metrics then gave the investigation a different direction. CPU was heavily saturated, storage I/O pressure was significant, and the slow-query evidence showed that returning a small result could require a very large amount of work.
Anonymized real incident. The investigation sequence and developer handoff come from the retained firsthand account. Retained slow-query artifacts corroborate the Relevanssi query patterns and expensive executions. Commands and SQL below are reconstructed examples; exact dates, identifiers and distinctive measurements are withheld. The precise developer fix and post-fix performance measurements were not retained.
From the gateway timeout to the database wait
The matching NGINX evidence established that requests reached the proxy and the upstream path did not return in time. That was enough to move downstream, but not enough to blame PHP-FPM or Kubernetes.
I checked the workload and its request path rather than treating Running or Ready as a complete application test. A bad Service endpoint, a restarting process and an application blocked on a database can all leave a proxy waiting. The checks needed to distinguish those possibilities before any timeout setting changed.
The retained account describes PHP-FPM waiting on database responses. It does not preserve exact worker-queue measurements. That boundary matters: I can explain why a database wait occupies workers, but I cannot turn an unrecorded queue depth into an incident fact.
Correlating database pressure with the slow-query files
CPU and storage-I/O observations showed the database under pressure. They did not identify which query or application action produced it.
That distinction is easy to lose during an outage. A database graph can encourage a larger instance as the first response. More capacity may be a useful containment option, but it does not explain why a plugin report suddenly performs hours of work or why application requests compete with it.
The retained slow-query files contain expensive Relevanssi reporting statements as well as expensive search statements. They also include other costly WordPress SQL. The evidence supports Relevanssi as a substantial contributor to the pressure; it does not support claiming that it was the only load on the database.
A limit on output did not limit the work
The reporting fingerprint counted distinct searches, filtered for searches without results, grouped by the query text and ordered the aggregate before returning a small list. Its time range spanned accumulated history.
-- Reconstructed shape; dates, prefix and report size are illustrative.
SELECT COUNT(DISTINCT id) AS occurrences, query, hits
FROM demo_relevanssi_log
WHERE time >= '2024-01-01'
AND time < '2025-01-01'
AND hits = 0
GROUP BY query, hits
ORDER BY occurrences DESC
LIMIT 25;
This is not the captured customer SQL. It preserves the explanatory shape while using a synthetic table prefix and time window. LIMIT restricts the returned groups; it does not promise that the server can identify those groups without reading and aggregating a much larger input.
The original evidence contains executions measured in hours and rows examined in the millions for a small returned result. Those observations explain why “the report only asks for a short list” was not a reassuring capacity argument.
Rows examined is still not a direct count of physical disk reads, and the largest value is not proof of the table’s exact size. Repeated work, caching and execution strategy can affect the relationship. Query cost needs interpretation, not a dramatic ratio presented as a complete diagnosis.
What the slow-log fields establish
Reconstructed sample log; all values are illustrative
Query_time: 95.000000
Lock_time: 0.000000
Rows_sent: 25
Rows_examined: 2000000
The fields separate elapsed execution, reported lock acquisition and result volume. A zero reported Lock_time is not proof that every possible engine wait was absent. Nor does elapsed query time reveal how much was CPU work versus I/O wait by itself.
Slow-log order also needs care because statements are recorded after execution. Overlapping samples cannot be added together to invent outage duration. The retained analysis includes samples from separate periods; those support recurrence of a costly pattern, not one continuous incident.
The useful handoff combines a query fingerprint, its observed cost and the matching resource window. It avoids claiming an optimizer plan that was never captured.
Search had a separate expensive shape
The other Relevanssi pattern combined forward and reverse prefix matching with distinct results, a published-post condition, ranking and sorting. That is a different application path from the reporting query and deserves its own explanation.
An autocomplete feature can issue several searches during one interaction. Even when each query examines fewer rows than a historical report, request frequency and concurrency can turn it into significant database work. The application-side evidence in the retained account supports reviewing that search behavior alongside the reporting workload.
It would be convenient to conclude that an index was missing. I did not recover the execution plan, index inventory or exact retention configuration needed to prove that. The captured SQL provides candidate work to investigate, not permission to prescribe a production index from the article alone.
What I would collect before choosing a query change
On an authorized diagnostic connection, current activity can establish whether the same shape is still running:
SHOW FULL PROCESSLIST;
SHOW GLOBAL STATUS LIKE 'Threads_running';
Those results may contain private query values and should remain inside the incident boundary. Use a sanitized statement on a representative test copy to inspect the plan and evaluate changes. EXPLAIN ANALYZE executes the statement; do not casually run the expensive query again on a saturated production database just to obtain a richer explanation.
Candidate repairs can include reducing report scope, moving reporting work away from the request path, changing search behavior or implementing a reviewed retention policy. Each requires application and data-owner agreement. None is asserted as the historical fix in this incident.
The handoff, recovery and missing remediation diff
I shared the request-path evidence, database pressure and expensive SQL behavior with the development team. The application was subsequently remediated and availability returned, according to the retained firsthand account.
The exact developer change is missing from the record. I cannot honestly say that the team added an index, deleted log history, disabled statistics or rewrote a particular function. I also cannot publish a before-and-after latency or CPU percentage without the missing measurements.
A stronger recovery record would include the remediation diff and representative page, search, worker and database measurements after the change. Without those artifacts, an exact fix remains unverified even though the account records restored availability.
Evidence to carry into a recurrence
The surviving evidence supports a focused starting point: historical reporting aggregates and application search can both impose substantial database work. Inspect their concurrency, input range and execution plans on an appropriate test copy before choosing retention, indexing or application changes.
Keep the query fingerprint, resource window and request-path observation together. That is the developer handoff I can support from this incident. An asserted index fix or a precise performance gain would go beyond the record.
Sources and further investigation
References support the protocol and product behavior discussed here; they are not evidence that the illustrative scenario occurred.
- MySQL slow-query fields
- MySQL EXPLAIN and EXPLAIN ANALYZE
- Relevanssi search logging
- MySQL 8.0 Reference Manual: The Slow Query Log
- MySQL 8.0 Reference Manual: EXPLAIN
