长期持续调用SHOW STATUS LIKE 'Uptime'保活MySQL连接是否会给服务器施压?
SHOW STATUS LIKE 'Uptime' Queries Stress MySQL Long-Term? Great question—let’s break down whether this stopgap will cause issues over time:
The query itself is extremely low-overhead
SHOW STATUS LIKE 'Uptime'doesn’t touch any tables, perform disk I/O, or run complex calculations. It just fetches a single in-memory system variable that MySQL tracks constantly. The server can handle this query in microseconds, with barely measurable CPU or memory usage.A 10-second interval is trivial for MySQL
Even if you’re running this query every 10 seconds, that’s only 6 times per minute, 360 times per hour. MySQL is designed to handle thousands of queries per second under normal load—this frequency is a drop in the bucket. Unless you have hundreds of connections all doing this simultaneously, you won’t notice any impact.Minor caveats to keep in mind
- If you scale to many client connections all running this same ping query, the total number of open connections could add up. But for a single (or small number of) connection(s), this isn’t a concern.
- While this works as a temporary fix, it’s worth double-checking if you missed any MySQL configuration tweaks. For example, ensuring
wait_timeoutandinteractive_timeoutare set correctly for your use case (though you mentioned adjusting settings didn’t resolve the original disconnect issue, so this is just a note). - Some monitoring tools might count this as a "query" in metrics, but don’t confuse that with actual resource load—this won’t skew meaningful performance stats.
In short: This approach is safe for long-term use. The server won’t feel any meaningful pressure from this frequency of such a lightweight query.
内容的提问来源于stack exchange,提问作者Rusty Shackleford

