Command Palette

Search for a command to run...

UnylyUnyly
Назад к скиллам

woocommerce-performance

БесплатноБез исполняемых скриптовНе проверен

Fix slow WooCommerce stores by optimizing database queries, clearing transients, enabling Redis object caching, and configuring page caching

finsilabsот finsilabs★ 69 звёзд на GitHub

Об этом скилле

WooCommerce Performance

Overview

WooCommerce performance problems typically stem from five sources: expensive product queries with un-indexed meta tables, unbounded AJAX cart/checkout calls, missing persistent object cache, bloated wp_options autoload data, and a growing wp_woocommerce_sessions and order table without cleanup. This skill covers profiling, query optimization, Redis object caching, and scheduled maintenance routines.

When to Use This Skill

  • When store pages are slow to load under moderate traffic (hundreds of concurrent users)
  • When server CPU spikes during WooCommerce AJAX calls (add-to-cart, shipping calculation)
  • When MySQL query time shows in New Relic or Query Monitor as the primary bottleneck
  • When the wp_options table autoload size exceeds 1–2 MB
  • When wp_woocommerce_sessions has millions of rows slowing down session lookups
  • When implementing Redis or Memcached to reduce MySQL load on a high-traffic store

Core Instructions

  1. Profile first with Query Monitor

    Install Query Monitor plugin to identify slow queries in the admin and frontend:

    # Via WP-CLI
    wp plugin install query-monitor --activate
    

    Focus on:

    • Queries per page load (> 50 is a concern)
    • Duplicate queries (same query run multiple times)
    • Slow queries (> 100ms individual queries)
    • Large result sets (queries returning thousands of rows)

    For production profiling, enable MySQL slow query log:

    SET GLOBAL slow_query_log = 'ON';
    SET GLOBAL long_query_time = 0.5;
    SET GLOBAL slow_query_log_file = '/var/log/mysql/slow.log';
    
  2. Enable Redis persistent object cache

    The single highest-impact optimization for WooCommerce. Without it, every page load re-fetches the same product data from MySQL:

    # Install Redis server
    sudo apt install redis-server
    
    # Install the Redis Object Cache plugin
    wp plugin install redis-cache --activate
    wp redis enable
    

    Configure in wp-config.php:

    define('WP_REDIS_HOST', '127.0.0.1');
    define('WP_REDIS_PORT', 6379);
    define('WP_REDIS_DATABASE', 0);
    define('WP_REDIS_TIMEOUT', 1);
    define('WP_REDIS_READ_TIMEOUT', 1);
    define('WP_REDIS_MAXTTL', 86400); // 24 hours max TTL
    
    // Selective cache groups — exclude user sessions from Redis (they change constantly)
    define('WP_REDIS_IGNORED_GROUPS', ['wc_session_id', 'counts', 'plugins']);
    
  3. Optimize WooCommerce-specific database queries

    <?php
    
    // Add missing indexes for common WooCommerce product queries
    // Run once via WP-CLI: wp eval-file add-indexes.php
    
    global $wpdb;
    
    // Index for product meta queries (stock status, visibility, price)
    $wpdb->query("
        ALTER TABLE {$wpdb->postmeta}
        ADD INDEX wc_product_meta_lookup (meta_key(32), meta_value(64))
    ");
    
    // Index for order meta queries
    $wpdb->query("
        ALTER TABLE {$wpdb->postmeta}
        ADD INDEX wc_order_customer_lookup (meta_key(32), meta_value(100))
    ");
    

    Use WooCommerce's HPOS (High-Performance Order Storage) to move orders out of post meta:

    // wp-config.php — enable HPOS (WooCommerce 7.1+)
    // This is configured via WooCommerce Settings → Advanced → Features
    // Enables dedicated order tables: wp_wc_orders, wp_wc_order_items, etc.
    
    # Check HPOS status
    wp wc hpos status
    # Migrate orders to HPOS
    wp wc hpos migrate --batch-size=500
    
  4. Clean up transients, sessions, and log tables

    <?php
    // Scheduled cleanup — run daily via Action Scheduler
    
    add_action('my_plugin_daily_cleanup', function () {
        global $wpdb;
    
        // Delete expired WooCommerce sessions (older than 48 hours)
        $expiry_threshold = time() - (48 * HOUR_IN_SECONDS);
        $wpdb->query($wpdb->prepare("
            DELETE FROM {$wpdb->prefix}woocommerce_sessions
            WHERE session_expiry < %d
            LIMIT 5000
        ", $expiry_threshold));
    
        // Delete expired transients
        $wpdb->query("
            DELETE FROM {$wpdb->options}
            WHERE option_name LIKE '_transient_timeout_%'
              AND option_value < UNIX_TIMESTAMP()
            LIMIT 5000
        ");
        $wpdb->query("
            DELETE t FROM {$wpdb->options} t
            LEFT JOIN {$wpdb->options} e
                ON e.option_name = REPLACE(t.option_name, '_transient_', '_transient_timeout_')
            WHERE t.option_name LIKE '_transient_%'
              AND e.option_id IS NULL
            LIMIT 5000
        ");
    
        // Rotate WooCommerce logs older than 30 days
        $wpdb->query("
            DELETE FROM {$wpdb->prefix}woocommerce_log
            WHERE timestamp < DATE_SUB(NOW(), INTERVAL 30 DAY)
            LIMIT 10000
        ");
    });
    
    // Register the scheduled event
    add_action('init', function () {
        if (!as_next_scheduled_action('my_plugin_daily_cleanup')) {
            as_schedule_recurring_action(strtot
    
Полный SKILL.md на GitHub

Установить woocommerce-performance в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

claude-code
cursor
gemini-cli
copilot
codex-cli
kiro
opencode

Вложенные файлы

evals/database-cleanup-and-session-maintenance/criteria.jsonevals/database-cleanup-and-session-maintenance/task.mdevals/query-optimization-and-n-1-prevention/criteria.jsonevals/query-optimization-and-n-1-prevention/task.mdevals/redis-object-cache-configuration/criteria.jsonevals/redis-object-cache-configuration/task.mdtile.json

FAQ

Что делает скилл woocommerce-performance?

Fix slow WooCommerce stores by optimizing database queries, clearing transients, enabling Redis object caching, and configuring page caching

Как установить скилл woocommerce-performance?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл woocommerce-performance запускает скрипты?

Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.

Похожие скиллы

Сравнить woocommerce-performance с