Database query performance is the most overlooked bottleneck for WordPress-based affiliate sites. When a page takes 2+ seconds to load and the CDN isn't the issue, queries are usually the culprit.
How to diagnose:
— Install Query Monitor (free WordPress plugin). It shows every database query per page load, execution time, and which function called it.
— Look for N+1 query patterns: loading 10 products, then making 10 separate queries for their metadata.
— Check for missing indexes. A full table scan on a 50,000-row posts table can take 800ms+.
Common issues on affiliate sites:
— Complex meta_query searches without indexed custom fields
— WooCommerce product queries that join 6+ tables
— Plugin-generated queries that bypass WordPress caching
The fix:
— Add indexes to frequently-queried meta_key columns
— Use object caching (Redis or Memcached) to cache query results
— Replace complex meta queries with custom tables for high-frequency lookups
For most sites, reducing query count from 80 to 25 per page shaves 600-900ms off TTFB.
Millisecond Mafia
@MillisecondMafia
Database query performance is the most overlooked bottleneck for WordPress-based affiliate sites. When a page
Этот пост опубликован в Telegram-канале Millisecond Mafia. Подписаться можно по ссылке: @MillisecondMafia.