| name | wordpress-query-optimization |
| description | Audit WordPress plugin file(s) for database query performance issues: uncached queries on always-run admin hooks, N+1 queries in loops, missing $wpdb->prepare(), blocking work on save/update requests (post saves, options/settings saves, term/user saves, activation/import), and stale cache after writes. Use when reviewing a file for DB performance or when a feature is slow on admin pages, post save, or listing screens.
|
WordPress Query Optimization
Audit the target file(s) for the common WordPress database performance problems and propose fixes.
This skill is vendor-neutral: the object-cache group used in fixes is resolved per Project
conventions, not hardcoded.
Project conventions (resolve before suggesting fixes)
Resolve the object-cache group in order, first hit wins:
AGENTS.md / CLAUDE.md — the documented cache group.
- Repo docs.
- The code itself — the group argument on existing
wp_cache_get/set/delete calls.
Use <cache-group> below as the placeholder for the resolved value. If the plugin has no
established group, recommend introducing one named after the plugin and using it consistently.
What to check
1. Uncached queries on always-run hooks
Look for $wpdb->get_* / $wpdb->query / WP_Query / get_posts inside callbacks that run on
every request or admin page load:
init / admin_init callbacks (especially before any is_admin() / screen guard)
admin_enqueue_scripts
- , , or any hook firing site-wide