A WordPress site that feels slow despite good hosting, good caching, and optimized images often has a database problem. One badly-written plugin query running on every page can add hundreds of milliseconds. Multiplied across slow queries, the site crawls. This guide covers identifying which queries are actually slow, why, and the practical fixes that improve real-world performance.
Symptoms of slow queries
- Time To First Byte (TTFB) is slow even with full-page caching off.
- Admin area feels sluggish loading list pages (posts, orders, comments).
- Backend operations time out (bulk delete, search-replace).
- High CPU usage on the database during normal traffic.
- WordPress complains about “Out of memory” during database operations.
Tool: Query Monitor
The essential plugin for WordPress query analysis. Install: WP Admin → Plugins → Add New → “Query Monitor.”
Once active (only visible to admin users, no perf impact for visitors):
- Browse to any page (front-end or admin).
- Admin bar shows page generation time and query count.
- Click the entry → opens Query Monitor panel.
- “Queries by Caller” — which plugin generated which queries.
- “Queries by Component” — grouped by plugin/theme.
- “Queries” tab — every query in execution order with timing.
- Sort by duration to see slowest first.
This immediately reveals whether queries are the bottleneck and which plugin is responsible.
Common slow query patterns
Autoloaded options bloat
Every WordPress page runs SELECT option_name, option_value FROM wp_options WHERE autoload = 'yes'. If wp_options has 10MB of autoloaded data, this single query is slow on every request.
Fix: Database optimization guide — find and disable bloated autoload options.
Unbounded postmeta queries
Plugin retrieves all post_meta for many posts without proper joins. Query takes seconds.
Pattern in Query Monitor: SELECT post_id, meta_value FROM wp_postmeta WHERE meta_key = '_some_value' with no LIMIT.
Fix: usually requires plugin update or replacement. Some plugins offer settings to limit scope.
WooCommerce order queries on every page
WooCommerce loads cart, checks for current customer, validates session — even on non-shop pages. Some plugins amplify this.
Fix:
- WooCommerce 8+ uses HPOS (High-Performance Order Storage) — enable it. WooCommerce → Settings → Advanced → Features.
- Dequeue WooCommerce scripts/styles from non-shop pages (plugin like “Disable WooCommerce Bloat”).
Search queries on large databases
WordPress default search uses LIKE ‘%query%’ which doesn’t use indexes. On large sites, search hangs.
Fix:
- Replace with Relevanssi or SearchWP — they build proper indexes.
- Or use Algolia / Meilisearch for external search.
Counted queries (transients gone wrong)
Plugin computes complex aggregation. Should cache in transient but somehow doesn’t. Repeats the slow query every page load.
Fix: identify plugin, check if there’s a “cache duration” setting. If not, look for alternative plugin.
Enabling MySQL slow query log
For server-side analysis (requires SSH and may need root):
Server-side analysis usually requires support intervention on shared hosting. If you have VPS access:
# /etc/my.cnf
slow_query_log = 1
slow_query_log_file = /var/log/mysql/slow.log
long_query_time = 1
After restart, slow queries (over 1 second) log to /var/log/mysql/slow.log. Analyze with mysqldumpslow.
For shared hosting on iWebVault: open a ticket asking for slow query log review for your database.
Object caching (the big lever)
Object cache stores query results in memory (Redis or Memcached) instead of executing queries. Same query within cache window returns instantly.
Redis on iWebVault
- If your hosting plan includes Redis, enable in cPanel.
- Install WordPress plugin “Redis Object Cache.”
- Plugin settings → Connect.
- If green, working.
Dramatic improvement on query-heavy sites. Especially admin area becomes snappy.
Alternative: LiteSpeed Cache built-in object cache
LiteSpeed Cache plugin → Cache → Object → enable with Redis or Memcached if available on your plan.
Indexing wp_postmeta and wp_options
Two tables that benefit enormously from custom indexes on large sites:
wp_postmeta index on meta_key
ALTER TABLE wp_postmeta ADD INDEX meta_key_idx (meta_key(190));
If site does many meta_key-based searches, this can dramatically speed them up.
wp_options autoload index
ALTER TABLE wp_options ADD INDEX autoload_idx (autoload);
WordPress core may already have this; check first via phpMyAdmin → wp_options → Structure tab.
When the problem is just too much data
Sometimes the site has genuinely too much data for shared hosting MySQL to handle.
- WooCommerce site with millions of orders → upgrade to VPS or use HPOS aggressively.
- Blog with 100k posts → consider table-level optimization, server tuning.
- Site with millions of postmeta rows → archive old data, refactor data model.
Past a certain scale, shared hosting MySQL just isn’t the right tool. Migrate to managed VPS or dedicated database.
Reducing query count overall
- Page caching — LiteSpeed Cache serving cached HTML means zero database queries for cached pages.
- Object caching — Same query within cache window returns from memory.
- Plugin audit — Each plugin adds queries. Reduce plugin count.
- Disable WordPress features you don’t use — Comments, XML-RPC, REST API for unauthenticated.
Specific plugins often guilty of slow queries
- Older versions of Yoast SEO (resolved in recent versions).
- Advanced Custom Fields with thousands of fields and no caching.
- WooCommerce Subscriptions on large stores without HPOS.
- Old “related posts” plugins doing full-table scans.
- Heavy revision plugins.
- Activity log plugins recording every action.
Query Monitor identifies the culprit specifically for your site.
Common questions
“How many queries should a WordPress page run?” Front-end cached: 0. Front-end uncached: 20-80 is normal, 100+ is concerning, 300+ usually means plugin chaos. Admin: often 100-200 normally; 500+ deserves investigation.
“My query monitor shows 600 queries per page — bad?” Likely yes. Investigate which plugin is causing. May indicate scale issue or specific buggy plugin.
“Object caching plugin shows zero hits.” Plugin can’t connect to Redis. Check Redis is enabled on your hosting plan; verify connection details.
“Adding indexes — will it break anything?” Indexes slow down inserts/updates slightly; speed up reads dramatically. Net positive for read-heavy WordPress sites. Always backup before.
“Can I limit how much database CPU one plugin uses?” Not really — MySQL gives all queries access to CPU. Resource limits at hosting level (CloudLinux LVE) cap total but not per-plugin.
What’s next
- Database cleanup: DB optimization.
- Plugin auditing: Plugin audits.
- Caching: LiteSpeed Cache.
- Resource limits: cPanel resource limits.
Most “slow WordPress” cases trace to one or two specific queries running too often. Query Monitor pinpoints them in minutes. Fix usually involves either replacing the responsible plugin, adding object caching, or cleaning up autoloaded options bloat. Sites that felt sluggish for years often become snappy after 30 minutes of focused query analysis.
Was this helpful?
Thanks for your feedback!