{"id":1361,"date":"2025-11-05T13:48:40","date_gmt":"2025-11-05T10:48:40","guid":{"rendered":"https:\/\/www.dchost.com\/blog\/the-woocommerce-mysql-innodb-tuning-checklist-i-wish-i-had-years-ago\/"},"modified":"2026-11-04T06:34:55","modified_gmt":"2026-11-04T03:34:55","slug":"woocommerce-mysql-innodb-tuning-checklist","status":"publish","type":"post","link":"https:\/\/www.dchost.com\/blog\/en\/woocommerce-mysql-innodb-tuning-checklist\/","title":{"rendered":"WooCommerce MySQL and InnoDB Tuning Checklist"},"content":{"rendered":"<div class=\"dchost-blog-content-wrapper\"><div id=\"toc_container\" role=\"navigation\" aria-label=\"Table of Contents\" data-nosnippet class=\"toc_transparent no_bullets toc_numbered toc_title_center\"><p class=\"toc_title\">\u0130\u00e7indekiler<\/p><ul class=\"toc_list\"><li><a href=\"#Investigating_WooCommerce_Database_Slowdowns\"><span class=\"toc_number toc_depth_1\">1.<\/span> Investigating WooCommerce Database Slowdowns<\/a><\/li><li><a href=\"#The_big_picture_what_WooCommerce_does_to_your_database\"><span class=\"toc_number toc_depth_1\">2.<\/span> The big picture: what WooCommerce does to your database<\/a><\/li><li><a href=\"#Sizing_the_InnoDB_buffer_pool_without_guesswork\"><span class=\"toc_number toc_depth_1\">3.<\/span> Sizing the InnoDB buffer pool without guesswork<\/a><ul><li><a href=\"#Think_of_the_buffer_pool_as_your_stores_memory\"><span class=\"toc_number toc_depth_2\">3.1.<\/span> Think of the buffer pool as your store\u2019s memory<\/a><\/li><li><a href=\"#Inventory_table_sizes_then_measure_the_working_set\"><span class=\"toc_number toc_depth_2\">3.2.<\/span> Inventory table sizes, then measure the working set<\/a><\/li><li><a href=\"#A_practical_rule_for_sizing\"><span class=\"toc_number toc_depth_2\">3.3.<\/span> A practical rule for sizing<\/a><\/li><li><a href=\"#Buffer_pool_instances_and_why_they_matter\"><span class=\"toc_number toc_depth_2\">3.4.<\/span> Buffer pool instances and why they matter<\/a><\/li><li><a href=\"#Redo_logs_and_flush_behavior\"><span class=\"toc_number toc_depth_2\">3.5.<\/span> Redo logs and flush behavior<\/a><\/li><li><a href=\"#Budget_memory_and_preserve_transaction_durability\"><span class=\"toc_number toc_depth_2\">3.6.<\/span> Budget memory and preserve transaction durability<\/a><\/li><li><a href=\"#Want_the_official_deep_dive\"><span class=\"toc_number toc_depth_2\">3.7.<\/span> Want the official deep dive?<\/a><\/li><\/ul><\/li><li><a href=\"#The_indexing_playbook_that_makes_WooCommerce_breathe\"><span class=\"toc_number toc_depth_1\">4.<\/span> The indexing playbook that makes WooCommerce breathe<\/a><ul><li><a href=\"#Start_with_the_usual_suspects_posts_and_postmeta\"><span class=\"toc_number toc_depth_2\">4.1.<\/span> Start with the usual suspects: posts and postmeta<\/a><\/li><li><a href=\"#Lean_on_WooCommerce_lookup_tables\"><span class=\"toc_number toc_depth_2\">4.2.<\/span> Lean on WooCommerce lookup tables<\/a><\/li><li><a href=\"#Sorting_and_covering_indexes\"><span class=\"toc_number toc_depth_2\">4.3.<\/span> Sorting and covering indexes<\/a><\/li><li><a href=\"#Be_mindful_of_long_text_columns\"><span class=\"toc_number toc_depth_2\">4.4.<\/span> Be mindful of long text columns<\/a><\/li><li><a href=\"#A_quick_note_on_utf8mb4_and_index_lengths\"><span class=\"toc_number toc_depth_2\">4.5.<\/span> A quick note on utf8mb4 and index lengths<\/a><\/li><\/ul><\/li><li><a href=\"#Slow_query_analysis_the_calm_repeatable_way\"><span class=\"toc_number toc_depth_1\">5.<\/span> Slow query analysis: the calm, repeatable way<\/a><ul><li><a href=\"#Turn_on_the_slow_query_log_selectively\"><span class=\"toc_number toc_depth_2\">5.1.<\/span> Turn on the slow query log (selectively)<\/a><\/li><li><a href=\"#Summarize_with_a_digest\"><span class=\"toc_number toc_depth_2\">5.2.<\/span> Summarize with a digest<\/a><\/li><li><a href=\"#EXPLAIN_and_EXPLAIN_ANALYZE_from_theory_to_reality\"><span class=\"toc_number toc_depth_2\">5.3.<\/span> EXPLAIN and EXPLAIN ANALYZE: from theory to reality<\/a><\/li><li><a href=\"#Performance_Schema_and_sys_digests_without_heavy_lifting\"><span class=\"toc_number toc_depth_2\">5.4.<\/span> Performance Schema and sys: digests without heavy lifting<\/a><\/li><\/ul><\/li><li><a href=\"#Locking_transactions_and_the_checkout_squeeze\"><span class=\"toc_number toc_depth_1\">6.<\/span> Locking, transactions, and the checkout squeeze<\/a><ul><li><a href=\"#Keep_transactions_short_and_sweet\"><span class=\"toc_number toc_depth_2\">6.1.<\/span> Keep transactions short and sweet<\/a><\/li><li><a href=\"#Handle_deadlock_rollbacks_explicitly\"><span class=\"toc_number toc_depth_2\">6.2.<\/span> Handle deadlock rollbacks explicitly<\/a><\/li><li><a href=\"#Read_replicas_for_reports\"><span class=\"toc_number toc_depth_2\">6.3.<\/span> Read replicas for reports<\/a><\/li><\/ul><\/li><li><a href=\"#A_Practical_Tuning_Checklist\"><span class=\"toc_number toc_depth_1\">7.<\/span> A Practical Tuning Checklist<\/a><ul><li><a href=\"#1_Snapshot_reality_before_touching_anything\"><span class=\"toc_number toc_depth_2\">7.1.<\/span> 1) Snapshot reality before touching anything<\/a><\/li><li><a href=\"#2_Right-size_the_buffer_pool\"><span class=\"toc_number toc_depth_2\">7.2.<\/span> 2) Right-size the buffer pool<\/a><\/li><li><a href=\"#3_Evaluate_indexes_against_actual_query_plans\"><span class=\"toc_number toc_depth_2\">7.3.<\/span> 3) Evaluate indexes against actual query plans<\/a><\/li><li><a href=\"#4_Catch_and_fix_slow_queries\"><span class=\"toc_number toc_depth_2\">7.4.<\/span> 4) Catch and fix slow queries<\/a><\/li><li><a href=\"#5_Flush_strategy_and_redo_sanity\"><span class=\"toc_number toc_depth_2\">7.5.<\/span> 5) Flush strategy and redo sanity<\/a><\/li><li><a href=\"#6_Keep_writes_tidy\"><span class=\"toc_number toc_depth_2\">7.6.<\/span> 6) Keep writes tidy<\/a><\/li><li><a href=\"#7_Stage_test_and_measure\"><span class=\"toc_number toc_depth_2\">7.7.<\/span> 7) Stage, test, and measure<\/a><\/li><\/ul><\/li><li><a href=\"#Common_Query_Patterns_to_Investigate\"><span class=\"toc_number toc_depth_1\">8.<\/span> Common Query Patterns to Investigate<\/a><ul><li><a href=\"#Show_products_in_category_X_order_by_date_paginate\"><span class=\"toc_number toc_depth_2\">8.1.<\/span> \u201cShow products in category X, order by date, paginate\u201d<\/a><\/li><li><a href=\"#Admin_orders_list_filtered_by_date_and_status\"><span class=\"toc_number toc_depth_2\">8.2.<\/span> \u201cAdmin orders list filtered by date and status\u201d<\/a><\/li><li><a href=\"#Search_product_by_SKU_then_fetch_variations\"><span class=\"toc_number toc_depth_2\">8.3.<\/span> \u201cSearch product by SKU then fetch variations\u201d<\/a><\/li><\/ul><\/li><li><a href=\"#A_word_about_the_rest_of_the_stack\"><span class=\"toc_number toc_depth_1\">9.<\/span> A word about the rest of the stack<\/a><\/li><li><a href=\"#Put_it_into_practice_a_quick_start_you_can_follow_today\"><span class=\"toc_number toc_depth_1\">10.<\/span> Put it into practice: a quick start you can follow today<\/a><\/li><li><a href=\"#Handy_references_youll_actually_use\"><span class=\"toc_number toc_depth_1\">11.<\/span> Handy references you\u2019ll actually use<\/a><\/li><li><a href=\"#Wrap-up_you_dont_need_magic_just_a_steady_checklist\"><span class=\"toc_number toc_depth_1\">12.<\/span> Wrap-up: you don\u2019t need magic, just a steady checklist<\/a><\/li><\/ul><\/div>\n<h2 id=\"section-1\"><span id=\"Investigating_WooCommerce_Database_Slowdowns\">Investigating WooCommerce Database Slowdowns<\/span><\/h2>\n<p>Busy sales periods can expose database bottlenecks even when overall server graphs look normal. This checklist focuses on MySQL\/InnoDB tuning for WooCommerce: a practical flow for investigating slow cart updates, checkout, and reports.<\/p>\n<p>If your site flies during quiet hours and crawls under load, MySQL\/InnoDB may be one bottleneck alongside PHP, plugins, and the theme. Database timings help distinguish those causes. This checklist covers buffer pool sizing, workload-specific indexes, and slow query analysis, including common pitfalls on busy stores.<\/p>\n<p>Record the database product and version, WooCommerce version and active order-storage mode before changing settings. This checklist distinguishes MySQL 8.0 and 8.4 where needed; MariaDB has its own configuration and execution-plan syntax. The examples describe an investigation process, not measured client results.<\/p>\n<h2 id=\"section-2\"><span id=\"The_big_picture_what_WooCommerce_does_to_your_database\">The big picture: what WooCommerce does to your database<\/span><\/h2>\n<p>Here\u2019s the thing about WooCommerce: it looks like WordPress, but it behaves like a transactional app. It doesn\u2019t just render pages \u2014 it creates orders, updates inventory, writes to multiple tables, and triggers a dozen small operations you don\u2019t notice until they stack up. Checkout hits order tables and lookup tables, product views hit post and postmeta, and admin dashboards love to aggregate, sort, and filter. Sprinkle in a few plugins, and suddenly you\u2019ve got queries doing full table scans or sorting massive result sets in temp tables.<\/p>\n<p>Three patterns are worth checking. First, read-heavy catalog browsing during campaigns can exceed an undersized buffer pool, leading to random I\/O and cache churn. Second, writes during checkout expose locking and index gaps you never noticed in staging. Third, \u201cinnocent\u201d admin reports run in business hours, touching millions of rows, and everybody else pays the price. Understanding those patterns is what makes the tuning process feel calm instead of chaotic.<\/p>\n<p>So the flow we\u2019ll follow is simple: right-size memory for hot data with the InnoDB buffer pool, put the right indexes where WooCommerce actually needs them, and then hunt slow queries with a sharp yet lightweight toolkit. Along the way, we\u2019ll review defaults against the workload and storage rather than assuming NVMe makes every default obsolete.<\/p>\n<h2 id=\"section-3\"><span id=\"Sizing_the_InnoDB_buffer_pool_without_guesswork\">Sizing the InnoDB buffer pool without guesswork<\/span><\/h2>\n<h3><span id=\"Think_of_the_buffer_pool_as_your_stores_memory\">Think of the buffer pool as your store\u2019s memory<\/span><\/h3>\n<p>If the buffer pool is the kitchen, everything goes fast when the ingredients you need are on the counter. When you keep running to the pantry (disk), dinner takes forever. For WooCommerce, the buffer pool is where InnoDB caches data and indexes. If it\u2019s too small, you\u2019ll see disk reads right when traffic spikes. If it\u2019s too big and the server also runs PHP-FPM and Nginx, you can starve the OS and swap \u2014 which is worse than being a little conservative.<\/p>\n<h3><span id=\"Inventory_table_sizes_then_measure_the_working_set\">Inventory table sizes, then measure the working set<\/span><\/h3>\n<p>With the WordPress database selected, this query estimates the total allocated InnoDB data and index size for that database. It is a starting inventory, not a measurement of the hot working set:<\/p>\n<pre class=\"language-sql line-numbers\"><code class=\"language-sql\">SELECT ROUND(SUM(data_length + index_length)\/1024\/1024) AS allocated_mb\nFROM information_schema.tables\nWHERE engine = &#039;InnoDB&#039; AND table_schema = DATABASE();<\/code><\/pre>\n<p>Trace the actual query paths. Products commonly use <strong>wp_posts<\/strong>, <strong>wp_postmeta<\/strong>, taxonomy tables and <strong>wp_wc_product_meta_lookup<\/strong>; active cart sessions may use <strong>wp_woocommerce_sessions<\/strong>. HPOS uses <strong>wp_wc_orders<\/strong>, <strong>wp_wc_order_addresses<\/strong>, <strong>wp_wc_order_operational_data<\/strong> and <strong>wp_wc_orders_meta<\/strong> as authoritative order tables when enabled. Legacy order storage uses posts\/postmeta. <strong>wp_wc_order_stats<\/strong> and <strong>wp_wc_order_product_lookup<\/strong> serve analytics. Replace <strong>wp_<\/strong> with your actual prefix. Regenerating stale lookup data through the relevant WooCommerce tools does not enable HPOS or rewrite arbitrary plugin SQL. Product image files normally live in the filesystem or object storage, so their file sizes are not buffer pool requirements.<\/p>\n<h3><span id=\"A_practical_rule_for_sizing\">A practical rule for sizing<\/span><\/h3>\n<p>Budget memory for the OS, connection buffers and other MySQL allocations, plus PHP workers, Redis and the web server when they share the host. A dedicated database server can allocate a larger share to its buffer pool, but no fixed percentage fits every store. After cache warm-up, compare interval read rates, storage latency and memory pressure under representative browsing and checkout load. Large table allocation alone does not prove that all those pages must fit in RAM.<\/p>\n<p>Check your current setting:<\/p>\n<pre class=\"language-bash line-numbers\"><code class=\"language-bash\">SHOW GLOBAL VARIABLES LIKE &#039;innodb_buffer_pool_size&#039;;\nSHOW GLOBAL STATUS LIKE &#039;Innodb_buffer_pool_reads&#039;;\nSHOW GLOBAL STATUS LIKE &#039;Innodb_buffer_pool_read_requests&#039;;<\/code><\/pre>\n<p>These read counters are cumulative. Compare their deltas over the same representative interval, after warm-up. A high physical-read rate alongside I\/O pressure may justify more memory or query\/index changes; a rising lifetime count alone does not.<\/p>\n<h3><span id=\"Buffer_pool_instances_and_why_they_matter\">Buffer pool instances and why they matter<\/span><\/h3>\n<p>MySQL 8.0 and 8.4 support <code>innodb_buffer_pool_instances<\/code> and <code>innodb_page_cleaners<\/code>, but their defaults differ. In MySQL 8.4, the page-cleaner default follows the number of buffer pool instances and is capped at that number. Multiple sufficiently large instances can reduce contention; matching the CPU count without measuring contention is not a sizing method. Check the installed version before carrying these settings into MariaDB.<\/p>\n<h3><span id=\"Redo_logs_and_flush_behavior\">Redo logs and flush behavior<\/span><\/h3>\n<p>MySQL <strong>8.0.30 and later<\/strong> use <code>innodb_redo_log_capacity<\/code> to control redo capacity. Earlier versions use <code>innodb_log_file_size<\/code> and <code>innodb_log_files_in_group<\/code>; MariaDB has different redo management. Adequate capacity can reduce checkpoint pressure during write bursts, but disk space and recovery time also matter. Follow the version-specific resizing procedure; do not manually delete redo files.<\/p>\n<p>For I\/O behavior, direct I\/O can reduce double buffering where the OS and filesystem support it; SSD storage alone does not determine the best flush method. Tune <code>innodb_flush_method<\/code> for that environment, and align <code>innodb_io_capacity<\/code> and its max setting with sustainable background-write capacity under load, leaving headroom for foreground work.<\/p>\n<h3><span id=\"Budget_memory_and_preserve_transaction_durability\">Budget memory and preserve transaction durability<\/span><\/h3>\n<p>Swapping active buffer pool pages can severely increase latency. Avoid sustained swapping through memory budgeting, not by disabling swap without considering out-of-memory risk. If you run web and DB together, be conservative with MySQL memory. If you\u2019re truly database heavy, consider dedicated resources. See the broader capacity discussion in <a href=\"https:\/\/www.dchost.com\/blog\/en\/woocommerce-capacity-planning-vcpu-ram-iops\/\">the guide to sizing vCPU, RAM and IOPS for WooCommerce<\/a> if you want a broader sizing strategy that matches your traffic profile. For order durability, keep <code>innodb_flush_log_at_trx_commit=1<\/code> and, when binary logging is enabled, assess it with <code>sync_binlog=1<\/code>. Values 0 or 2 can lose acknowledged transactions after a crash. UPS, RAID and backups do not eliminate that risk; storage must also honour flush requests.<\/p>\n<h3><span id=\"Want_the_official_deep_dive\">Want the official deep dive?<\/span><\/h3>\n<p>The MySQL docs on the buffer pool are genuinely helpful. If you want to peek under the hood, the reference on caching and internals is a good companion: <a href=\"https:\/\/dev.mysql.com\/doc\/refman\/8.0\/en\/innodb-buffer-pool.html\" rel=\"nofollow noopener\" target=\"_blank\">how the InnoDB buffer pool works and how to tune it<\/a>.<\/p>\n<h2 id=\"section-4\"><span id=\"The_indexing_playbook_that_makes_WooCommerce_breathe\">The indexing playbook that makes WooCommerce breathe<\/span><\/h2>\n<h3><span id=\"Start_with_the_usual_suspects_posts_and_postmeta\">Start with the usual suspects: posts and postmeta<\/span><\/h3>\n<p>WordPress leans hard on <strong>wp_posts<\/strong> and <strong>wp_postmeta<\/strong>. WooCommerce adds product data on top, and many catalog queries effectively become postmeta lookups. Core creates some indexes, but they\u2019re not always enough for real-world filters and sorts.<\/p>\n<p>For a query that constrains both <code>post_id<\/code> and <code>meta_key<\/code>, the following composite index is a <strong>candidate to test<\/strong>. It does not directly index a <code>meta_value<\/code> range or provide an efficient leading-key lookup on <code>meta_key<\/code> alone. First inspect existing indexes and EXPLAIN; test index build time, metadata-lock impact, disk headroom and write overhead in staging. The prefix may require checking full values after lookup. Run this DDL only if that investigation supports it:<\/p>\n<pre class=\"language-bash line-numbers\"><code class=\"language-bash\">CREATE INDEX idx_postmeta_postid_metakey\nON wp_postmeta (post_id, meta_key(191));<\/code><\/pre>\n<p>For numeric price or stock filters, use supported product data-access paths that can query <code>wc_product_meta_lookup<\/code> where appropriate. Full-text search is not a substitute for numeric range indexing. A plugin query against postmeta will not automatically switch to a lookup table after regeneration; changing its query path may require code changes and correct synchronization. Consider a purpose-built data model only when the existing supported paths do not meet the requirement.<\/p>\n<h3><span id=\"Lean_on_WooCommerce_lookup_tables\">Lean on WooCommerce lookup tables<\/span><\/h3>\n<p><strong>wc_product_meta_lookup<\/strong> contains product price, stock and SKU fields. Category and visibility filters still involve the relevant WordPress taxonomy relationships. <strong>wc_order_stats<\/strong> and <strong>wc_order_product_lookup<\/strong> are analytics tables, not the authoritative source for all admin order screens. Confirm whether the screen uses HPOS or legacy order storage before proposing an order-table index.<\/p>\n<p>For an analytics report filtered by one status and a date range, a status-leading composite index may be worth testing. Inspect the installed schema first: standard WooCommerce already creates order_id and product_id indexes on the product-order lookup table. Adding those again creates unnecessary maintenance work. Start with inspection rather than a set of unconditional CREATE INDEX statements:<\/p>\n<pre class=\"language-bash line-numbers\"><code class=\"language-bash\">SHOW INDEX FROM wp_wc_order_stats;\nSHOW INDEX FROM wp_wc_order_product_lookup;\nSHOW CREATE TABLE wp_wc_order_stats;\nSHOW CREATE TABLE wp_wc_order_product_lookup;<\/code><\/pre>\n<p>For equality on status followed by a date range, <code>(status, date_created_gmt)<\/code> can narrow the scan differently from a date-leading index; the latter may scan a broader range before checking status. Data distribution, joins and ORDER BY still determine whether either is worthwhile. The written order of WHERE predicates does not force execution order. HPOS may already have a suitable <code>(type, status, date_created_gmt)<\/code> index for a different order-list query; verify the real table and plan.<\/p>\n<h3><span id=\"Sorting_and_covering_indexes\">Sorting and covering indexes<\/span><\/h3>\n<p>An index can sometimes serve both filtering and ordering, and a covering index can reduce base-table lookups. Verify this against the exact SELECT columns, predicates, joins and direction of ORDER BY. Adding columns increases index size and write cost; it is not a free improvement. A filesort does not necessarily mean a disk sort, and sorting a small result set can be entirely reasonable.<\/p>\n<h3><span id=\"Be_mindful_of_long_text_columns\">Be mindful of long text columns<\/span><\/h3>\n<p>With the DYNAMIC row format, InnoDB can store long variable-length values fully off-page with a pointer in the clustered record. Whether it does so depends on row length and page size; small values may remain inline. Choose prefix indexes only where they support the actual lookup. They do not necessarily cover the full value or solve broad text searches.<\/p>\n<h3><span id=\"A_quick_note_on_utf8mb4_and_index_lengths\">A quick note on utf8mb4 and index lengths<\/span><\/h3>\n<p>Check the table character set, collation, row format and page-size-dependent key limit before adding an index. The familiar 191-character utf8mb4 prefix comes from older byte limits; it is not universally required on modern InnoDB. A composite key also includes its other columns, so a prefix that fits by itself may still exceed an older composite-key limit. Test the exact schema used by all source and replica versions.<\/p>\n<h2 id=\"section-5\"><span id=\"Slow_query_analysis_the_calm_repeatable_way\">Slow query analysis: the calm, repeatable way<\/span><\/h2>\n<h3><span id=\"Turn_on_the_slow_query_log_selectively\">Turn on the slow query log (selectively)<\/span><\/h3>\n<p>Use a bounded capture window and a threshold appropriate to the symptom. Record the original settings, confirm log-file permissions and free space, and restore the settings afterward. The following example requires administrative privileges and changes global logging configuration. Choose the window deliberately: log files can contain customer data and query literals.<\/p>\n<pre class=\"language-bash line-numbers\"><code class=\"language-bash\">-- Save these values before the capture.\nSHOW GLOBAL VARIABLES WHERE Variable_name IN\n  (&#039;slow_query_log&#039;, &#039;long_query_time&#039;,\n   &#039;log_queries_not_using_indexes&#039;, &#039;log_output&#039;, &#039;slow_query_log_file&#039;);\n\n-- Example capture settings; restore the recorded values afterward.\nSET GLOBAL log_output = &#039;FILE&#039;; -- output destination, not sampling\nSET GLOBAL long_query_time = 0.5;\nSET GLOBAL log_queries_not_using_indexes = OFF;\nSET GLOBAL slow_query_log = ON;<\/code><\/pre>\n<p>GLOBAL long_query_time sets the default for new sessions; existing pooled connections keep their session values. Account for that before interpreting a capture. FILE is a shared log-output setting and can also affect general-log output if that log is enabled. Limit retention, rotate files, restrict access and redact sensitive literals before sharing a report. Restore the recorded values when the capture ends. The official reference is handy if you want the knobs: <a href=\"https:\/\/dev.mysql.com\/doc\/refman\/8.0\/en\/slow-query-log.html\" rel=\"nofollow noopener\" target=\"_blank\">how the slow query log works and what to log<\/a>.<\/p>\n<h3><span id=\"Summarize_with_a_digest\">Summarize with a digest<\/span><\/h3>\n<p>Use a digest tool to group statements by pattern and rank their total response time. Compare call count, average latency, rows examined and the total contribution; a frequent moderately slow query can cost more than one unusually slow request. <a href=\"https:\/\/docs.percona.com\/percona-toolkit\/pt-query-digest.html\" rel=\"nofollow noopener\" target=\"_blank\">Percona\u2019s pt-query-digest documentation<\/a> explains the fields and input formats. Check the selected capture interval before comparing two reports.<\/p>\n<h3><span id=\"EXPLAIN_and_EXPLAIN_ANALYZE_from_theory_to_reality\">EXPLAIN and EXPLAIN ANALYZE: from theory to reality<\/span><\/h3>\n<p><code>EXPLAIN<\/code> shows the optimizer\u2019s plan. <code>EXPLAIN ANALYZE<\/code>, introduced in <strong>MySQL 8.0.18<\/strong>, actually executes the statement and reports iterator timing and row counts. Use representative staging data and controlled read-only queries first; an unbounded expensive query can still impose load, and supported data-changing statements can change data. MariaDB uses different ANALYZE syntax. This example targets an analytics table with a sample UTC date interval, not an admin order-storage migration:<\/p>\n<pre class=\"language-sql line-numbers\"><code class=\"language-sql\">EXPLAIN\nSELECT order_id, date_created_gmt, status\nFROM wp_wc_order_stats\nWHERE status = &#039;wc-completed&#039;\n  AND date_created_gmt &gt;= &#039;2026-10-01 00:00:00&#039;\n  AND date_created_gmt &lt; &#039;2026-11-01 00:00:00&#039;\nORDER BY date_created_gmt DESC\nLIMIT 50;\n\n-- MySQL 8.0.18+ only: executes the SELECT; use controlled staging data.\nEXPLAIN ANALYZE\nSELECT order_id, date_created_gmt, status\nFROM wp_wc_order_stats\nWHERE status = &#039;wc-completed&#039;\n  AND date_created_gmt &gt;= &#039;2026-10-01 00:00:00&#039;\n  AND date_created_gmt &lt; &#039;2026-11-01 00:00:00&#039;\nORDER BY date_created_gmt DESC\nLIMIT 50;<\/code><\/pre>\n<p>Investigate large scans, unexpectedly large join results and costly sorting or temporary-table work. Their presence alone does not prove a bad plan; compare row estimates with actual measurements and the required result. The official reference explains the fields: <a href=\"https:\/\/dev.mysql.com\/doc\/refman\/8.0\/en\/explain.html\" rel=\"nofollow noopener\" target=\"_blank\">EXPLAIN and query execution plans<\/a>.<\/p>\n<h3><span id=\"Performance_Schema_and_sys_digests_without_heavy_lifting\">Performance Schema and sys: digests without heavy lifting<\/span><\/h3>\n<p><code>performance_schema<\/code> aggregates statement patterns when the relevant collection and timing are enabled. The <code>sys<\/code> views make these statistics easier to read. For numerical ranking, use the raw timer below or the unformatted <code>sys.x$statement_analysis<\/code> view; a formatted latency string such as \u201c12 ms\u201d must not be treated as a numeric sort key. With the store database selected, this query ranks cumulative elapsed statement time:<\/p>\n<pre class=\"language-sql line-numbers\"><code class=\"language-sql\">SELECT DIGEST_TEXT, COUNT_STAR, SUM_TIMER_WAIT, SUM_ROWS_EXAMINED\nFROM performance_schema.events_statements_summary_by_digest\nWHERE SCHEMA_NAME = DATABASE()\nORDER BY SUM_TIMER_WAIT DESC\nLIMIT 10;<\/code><\/pre>\n<p><code>SUM_TIMER_WAIT<\/code> is elapsed statement time, not CPU consumption. Capture comparable intervals or calculate deltas, and account for counter resets and a full digest table. Avoid resetting shared production counters just for a report. Diagnostic tables may retain sample query text, so restrict access as you would for logs. A quiet summary can also mean collection is disabled.<\/p>\n<h2 id=\"section-6\"><span id=\"Locking_transactions_and_the_checkout_squeeze\">Locking, transactions, and the checkout squeeze<\/span><\/h2>\n<p>Checkout and extensions can perform several writes and external calls. Long transactions hold locks for longer and can increase waits or deadlocks. Measure the failing path, including hooks and background tasks, before assuming an extra index is sufficient.<\/p>\n<h3><span id=\"Keep_transactions_short_and_sweet\">Keep transactions short and sweet<\/span><\/h3>\n<p>Keep transaction boundaries as short as the business operation allows, use consistent row-access order and avoid unnecessary work while locks are held. Schedule large reports and batch updates away from peak periods when possible. Moving a job worker to another host does not remove its database load; jobs that update authoritative orders still require the appropriate write connection.<\/p>\n<h3><span id=\"Handle_deadlock_rollbacks_explicitly\">Handle deadlock rollbacks explicitly<\/span><\/h3>\n<p>When transactions deadlock, InnoDB selects a victim and rolls its transaction back. The application must handle the failure and, where appropriate, retry the complete transaction with a bounded policy. Use consistent access order, suitable indexes and shorter transactions to reduce recurrence; increasing a lock-wait timeout does not resolve a deadlock. External payment or notification effects need idempotency so a retry cannot charge or notify twice.<\/p>\n<h3><span id=\"Read_replicas_for_reports\">Read replicas for reports<\/span><\/h3>\n<p>A read replica can isolate suitable reporting queries, but WooCommerce does not automatically route every report correctly just because a replica exists. Configure and test routing explicitly, account for replica lag and decide which reports tolerate stale data. Checkout writes and reads requiring immediate read-after-write consistency must remain on an appropriate authoritative path. A replica is also not a replacement for recoverable backups.<\/p>\n<h2 id=\"section-7\"><span id=\"A_Practical_Tuning_Checklist\">A Practical Tuning Checklist<\/span><\/h2>\n<h3><span id=\"1_Snapshot_reality_before_touching_anything\">1) Snapshot reality before touching anything<\/span><\/h3>\n<p>Record versions, enabled order storage and a baseline for catalog, cart, checkout and reports. Compare p95\/p99 latency, errors, throughput, concurrency, memory pressure, disk latency and buffer pool counter deltas after warm-up. Use the same representative data and workload for before\/after testing; matching the hour of the day alone is insufficient.<\/p>\n<h3><span id=\"2_Right-size_the_buffer_pool\">2) Right-size the buffer pool<\/span><\/h3>\n<p>Estimate the working set and adjust the buffer pool within the overall memory budget. Monitor physical reads and latency after warm-up. Supported MySQL versions can resize the pool online, but the operation still requires resources and should be planned, monitored and reversible.<\/p>\n<h3><span id=\"3_Evaluate_indexes_against_actual_query_plans\">3) Evaluate indexes against actual query plans<\/span><\/h3>\n<p>Inspect existing indexes and table ownership first. Test a candidate only when the actual query plan supports it. Distinguish product lookup data, analytics and authoritative HPOS\/legacy orders. Rebuilding stale lookup data does not change a plugin\u2019s SQL; fixing its data-access path is a separate task.<\/p>\n<h3><span id=\"4_Catch_and_fix_slow_queries\">4) Catch and fix slow queries<\/span><\/h3>\n<p>Capture a bounded slow-log sample, restore the settings and digest the patterns. Use EXPLAIN first; use EXPLAIN ANALYZE only on a supported MySQL version and with the execution precautions above. Compare correct results, elapsed time and rows examined before deciding whether a query or index change helped.<\/p>\n<h3><span id=\"5_Flush_strategy_and_redo_sanity\">5) Flush strategy and redo sanity<\/span><\/h3>\n<p>Check version-specific redo capacity and supported flush methods against checkpoint pressure and sustainable background storage throughput. Preserve order durability. Also distinguish temporary-table engines: internal MEMORY tables use the lower of tmp_table_size and max_heap_table_size; MySQL 8.4 TempTable uses tmp_table_size per table plus global temptable_max_ram and temptable_max_mmap limits. Do not copy those semantics to all MySQL 8.0 minors or MariaDB. Raising limits or session buffers without a concurrency budget can exhaust RAM.<\/p>\n<h3><span id=\"6_Keep_writes_tidy\">6) Keep writes tidy<\/span><\/h3>\n<p>Keep transactions short, access rows predictably and schedule large admin jobs where possible. Verify deadlock handling, stock updates, order state and payment idempotency during load tests. Database latency improvements must not alter checkout results.<\/p>\n<h3><span id=\"7_Stage_test_and_measure\">7) Stage, test, and measure<\/span><\/h3>\n<p>Schema changes are easier than they used to be, but they still deserve a dress rehearsal. Verify recovery from backup, test on representative staging data and validate the actual queries. Plan disk headroom, metadata locks, build I\/O, deployment timing and rollback; online DDL still has operational impact. If you\u2019re weighing backup strategies or point-in-time recovery while planning changes, see the guide to <a href=\"https:\/\/www.dchost.com\/blog\/en\/mysql-mariadb-backups-mysqldump-xtrabackup-pitr\/\">mysqldump, XtraBackup and point-in-time recovery<\/a>.<\/p>\n<h2 id=\"section-8\"><span id=\"Common_Query_Patterns_to_Investigate\">Common Query Patterns to Investigate<\/span><\/h2>\n<h3><span id=\"Show_products_in_category_X_order_by_date_paginate\">\u201cShow products in category X, order by date, paginate\u201d<\/span><\/h3>\n<p>Inspect the joins and actual row counts before adding indexes. WordPress already creates a primary key on <code>(object_id, term_taxonomy_id)<\/code> and a taxonomy-ID index in its relationships table, along with posts indexes for type\/status\/date and parent. Confirm what the installed schema provides, whether plugin meta filters change the plan, and whether deep offset pagination dominates cost. A single composite index cannot automatically cover filtering and sorting across every joined table.<\/p>\n<h3><span id=\"Admin_orders_list_filtered_by_date_and_status\">\u201cAdmin orders list filtered by date and status\u201d<\/span><\/h3>\n<p>Identify whether the list reads HPOS tables or legacy posts\/postmeta, then inspect that query. An index on <code>wc_order_stats<\/code> does not generally fix the authoritative admin order list. For analytics, inspect its own table and predicates; <code>wc_order_product_lookup<\/code> normally already has an order_id index. Regenerating analytics data is a consistency operation, not a substitute for choosing the correct order store.<\/p>\n<h3><span id=\"Search_product_by_SKU_then_fetch_variations\">\u201cSearch product by SKU then fetch variations\u201d<\/span><\/h3>\n<p>Use supported WooCommerce product lookups and inspect the SKU query. The product metadata lookup schema already includes an SKU prefix index, so adding another blindly can be redundant. Exact matching and a suitable prefix search differ from <code>LIKE '%term%'<\/code>, which generally cannot use a normal B-tree for a selective prefix lookup. Verify variation\/parent handling and full SKU equality where required; a prefix index still needs full-value checks.<\/p>\n<h2 id=\"section-9\"><span id=\"A_word_about_the_rest_of_the_stack\">A word about the rest of the stack<\/span><\/h2>\n<p>Your database isn\u2019t a lone ranger. PHP-FPM worker counts, OPcache, and object caching all play a role in whether you feel the benefit of database tuning. If you haven\u2019t already tuned the rest of your stack, see <a href=\"https:\/\/www.dchost.com\/blog\/en\/wordpress-server-tuning-php-redis-mysql\/\">the WordPress and WooCommerce server-side optimization guide<\/a>. And if you\u2019re at the \u201cwhat size box do I need?\u201d stage, you might enjoy <a href=\"https:\/\/www.dchost.com\/blog\/en\/vps-sizing-woocommerce-laravel-nodejs\/\">how to choose VPS resources for WooCommerce<\/a>. Measure application latency and errors as well as database metrics to see whether a change helps users. Avoid universal swap or THP changes; match OS tuning to the documented version and measured behaviour.<\/p>\n<h2 id=\"section-10\"><span id=\"Put_it_into_practice_a_quick_start_you_can_follow_today\">Put it into practice: a quick start you can follow today<\/span><\/h2>\n<p>Start with a focused investigation window. Capture a representative slow-query sample, restore the logging settings, and identify the patterns contributing most to total time. Test one justified query, index or memory change at a time. Repeat the same workload after warm-up and compare latency, errors and resource use. There is no required number of new indexes and no guaranteed one-day result.<\/p>\n<p>If you can go a little deeper, review redo capacity and I\/O settings to keep flushes smooth; verify WooCommerce lookup tables are healthy and used; and check that admin reports aren\u2019t stealing cycles at 11 a.m. Validate cache rules for product data while preserving cart, checkout and personalized responses. If you\u2019re curious about the object cache layer and eviction behavior, see <a href=\"https:\/\/www.dchost.com\/blog\/en\/redis-vs-memcached-wordpress-woocommerce\/\">Redis vs Memcached: TTL and eviction behaviour<\/a>. It pairs nicely with your MySQL gains.<\/p>\n<h2 id=\"section-11\"><span id=\"Handy_references_youll_actually_use\">Handy references you\u2019ll actually use<\/span><\/h2>\n<p>Use the official documentation for the installed version when interpreting settings and query plans:<\/p>\n<p>\u2022 <a href=\"https:\/\/dev.mysql.com\/doc\/refman\/8.0\/en\/innodb-buffer-pool.html\" rel=\"nofollow noopener\" target=\"_blank\">InnoDB buffer pool behavior and sizing<\/a><br \/>\u2022 <a href=\"https:\/\/dev.mysql.com\/doc\/refman\/8.0\/en\/slow-query-log.html\" rel=\"nofollow noopener\" target=\"_blank\">Slow query log settings and options<\/a><br \/>\u2022 <a href=\"https:\/\/dev.mysql.com\/doc\/refman\/8.0\/en\/explain.html\" rel=\"nofollow noopener\" target=\"_blank\">EXPLAIN and execution plans<\/a><\/p>\n<p>For the schema distinctions, consult the <a href=\"https:\/\/developer.woocommerce.com\/docs\/features\/orders\/high-performance-order-storage\/\" rel=\"nofollow noopener\" target=\"_blank\">WooCommerce HPOS documentation<\/a>. For version-sensitive settings, use the <a href=\"https:\/\/dev.mysql.com\/doc\/refman\/8.4\/en\/innodb-parameters.html\" rel=\"nofollow noopener\" target=\"_blank\">MySQL 8.4 InnoDB variable reference<\/a> and <a href=\"https:\/\/dev.mysql.com\/doc\/refman\/8.4\/en\/internal-temporary-tables.html\" rel=\"nofollow noopener\" target=\"_blank\">temporary-table documentation<\/a>.<\/p>\n<h2 id=\"section-12\"><span id=\"Wrap-up_you_dont_need_magic_just_a_steady_checklist\">Wrap-up: you don\u2019t need magic, just a steady checklist<\/span><\/h2>\n<p>Effective WooCommerce database tuning connects a measured symptom to a specific query path or resource constraint. Keep hot InnoDB pages in memory where the budget allows, choose indexes for demonstrated access patterns and investigate the statements that account for substantial time. Recheck order correctness and write costs alongside performance.<\/p>\n<p>Prioritize three tasks: establish a comparable baseline, test one evidence-backed change and repeat the measurement. Keep existing indexes that serve real workloads; add or remove them only after checking the broader impact. Use execution-plan tools with the correct version and a clear understanding of which commands actually run the query.<\/p>\n<p>Capacity planning, recoverable backups and PHP\/object-cache configuration remain part of the same operational plan. Keep a record of each change, its observed result and how to reverse it. Revisit the checklist after material workload or plugin changes rather than treating one tuning session as a permanent guarantee.<\/p>\n<\/div>","protected":false},"excerpt":{"rendered":"<p>A practical checklist for WooCommerce database tuning: budget buffer pool memory, distinguish product, analytics and order tables, inspect query plans and preserve checkout durability.<\/p>\n","protected":false},"author":1,"featured_media":9950,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[184],"tags":[],"class_list":["post-1361","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-technology"],"_links":{"self":[{"href":"https:\/\/www.dchost.com\/blog\/en\/wp-json\/wp\/v2\/posts\/1361","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.dchost.com\/blog\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.dchost.com\/blog\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.dchost.com\/blog\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.dchost.com\/blog\/en\/wp-json\/wp\/v2\/comments?post=1361"}],"version-history":[{"count":5,"href":"https:\/\/www.dchost.com\/blog\/en\/wp-json\/wp\/v2\/posts\/1361\/revisions"}],"predecessor-version":[{"id":9952,"href":"https:\/\/www.dchost.com\/blog\/en\/wp-json\/wp\/v2\/posts\/1361\/revisions\/9952"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.dchost.com\/blog\/en\/wp-json\/wp\/v2\/media\/9950"}],"wp:attachment":[{"href":"https:\/\/www.dchost.com\/blog\/en\/wp-json\/wp\/v2\/media?parent=1361"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.dchost.com\/blog\/en\/wp-json\/wp\/v2\/categories?post=1361"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.dchost.com\/blog\/en\/wp-json\/wp\/v2\/tags?post=1361"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}