What “Sleep” Means in MySQL
A Sleep process is a client connection that’s still open to the MySQL server, but not actively doing anything at that moment.
Think of it like a customer who’s sitting at a café table with their coffee cup but hasn’t placed a new order. They’re not taking up the barista’s time right now, but they’re still occupying a seat.
In SQL terms:
-
The connection is established.
-
No query is currently running.
-
It’s “idling” until the client either issues a new query or disconnects.
Why Sleep Processes Happen
-
Persistent connections: Some PHP apps (especially with mysql_pconnect) keep connections open rather than reconnecting for each page load.
-
Bad application behaviour: A script opens a connection and never closes it.
-
Slow clients: The client sends queries sporadically but holds the connection open the whole time.
When Sleep Processes Are a Problem
A few Sleep processes are normal. But problems arise when administrators hundreds of them piling up on the server, these can include:
-
They can exhaust MySQL’s max_connections limit, blocking new queries.
-
They can hold onto memory unnecessarily.
-
They make the server feel “sluggish” because you’ve got too many idle but open sessions.
Why Sleep Processes Happen
-
Persistent connections: Some PHP apps (especially with mysql_pconnect) keep connections open rather than reconnecting for each page load.
-
Bad application behaviour: A script opens a connection and never closes it.
-
Slow clients: The client sends queries sporadically but holds the connection open the whole time.
Why Elementor (and page builders in general) Cause Sleep Processes
-
AJAX-heavy editing
-
When you edit a page in Elementor, it fires off dozens of AJAX requests in the background to load widgets, templates, images, and save changes.
-
Each request can open a MySQL connection. If the script doesn’t explicitly close it (or if persistent connections are on), the connection drops into Sleep.
-
-
Autosave and Revisions
-
WordPress autosaves drafts every few seconds while editing.
-
Each autosave = new write query to the database.
-
If the editor is open for a long session, that can leave a trail of idle connections.
-
-
Poorly optimised plugins
-
Some Elementor add-ons query the database inefficiently (loading all templates, fetching every meta value, etc.).
-
If these queries aren’t closed quickly, they show up as Sleep.
-
What Clients Can Do (Specific to WordPress + Elementor)
-
Keep editing sessions short: Leaving the editor open for hours can accumulate Sleep processes.
-
Limit simultaneous editors: Multiple people editing pages at once = multiple idle connections.
-
Optimise the database: Use a plugin like WP-Optimize to reduce bloat from postmeta, revisions, and autoloaded options.
-
Disable persistent connections: In wp-config.php, make sure persistent DB connections aren’t being forced.
-
Check plugins: Some Elementor add-ons are notorious for database inefficiency. Disabling one can cut Sleep processes dramatically.
