<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Abdullah Web Dev</title>
    <description>The latest articles on DEV Community by Abdullah Web Dev (@theabdullahwebdev).</description>
    <link>https://dev.to/theabdullahwebdev</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4000554%2F01fdafcf-f0ba-4cf4-b106-1594fe5766a5.jpg</url>
      <title>DEV Community: Abdullah Web Dev</title>
      <link>https://dev.to/theabdullahwebdev</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/theabdullahwebdev"/>
    <language>en</language>
    <item>
      <title>wp_postmeta Has No Index on meta_value — And That Missing Index Is Why Your WooCommerce Store Crawls</title>
      <dc:creator>Abdullah Web Dev</dc:creator>
      <pubDate>Mon, 19 Oct 2026 08:14:07 +0000</pubDate>
      <link>https://dev.to/theabdullahwebdev/wppostmeta-has-no-index-on-metavalue-and-that-missing-index-is-why-your-woocommerce-store-crawls-h2f</link>
      <guid>https://dev.to/theabdullahwebdev/wppostmeta-has-no-index-on-metavalue-and-that-missing-index-is-why-your-woocommerce-store-crawls-h2f</guid>
      <description>&lt;p&gt;Every product lookup on a WooCommerce store reads the wp_postmeta table. And one missing index in that table is why so many stores get slower as they grow.&lt;/p&gt;

&lt;h2&gt;
  
  
  Look at the table
&lt;/h2&gt;

&lt;p&gt;wp_postmeta has indexes on meta_id, post_id and meta_key (with a 191-character prefix). But look at meta_value:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;KEY&lt;/span&gt; &lt;span class="n"&gt;meta_key&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;meta_key&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;191&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;span class="err"&gt;→&lt;/span&gt; &lt;span class="n"&gt;meta_value&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;LONGTEXT&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;not&lt;/span&gt; &lt;span class="n"&gt;indexable&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;meta_value is a LONGTEXT column with &lt;strong&gt;no index at all&lt;/strong&gt;. Any query that searches or filters by a meta &lt;em&gt;value&lt;/em&gt; cannot use an index. MySQL has no shortcut — it reads the whole table, row by row.&lt;/p&gt;

&lt;h2&gt;
  
  
  The math nobody does
&lt;/h2&gt;

&lt;p&gt;One product is not one row in wp_postmeta. One product is &lt;strong&gt;30–100 rows&lt;/strong&gt; — price, sale price, stock status, SKU, thumbnail ID, gallery, attributes, and everything plugins add.&lt;/p&gt;

&lt;p&gt;A variable product with 20 variations? &lt;strong&gt;500+ rows&lt;/strong&gt; for that single product.&lt;/p&gt;

&lt;p&gt;A store with 2,000 products easily reaches &lt;strong&gt;200,000–500,000 rows&lt;/strong&gt; in wp_postmeta.&lt;/p&gt;

&lt;h2&gt;
  
  
  What one lookup costs
&lt;/h2&gt;

&lt;p&gt;On a table of 300,000 rows, a single meta_value lookup can scan &lt;strong&gt;every row&lt;/strong&gt; and take &lt;strong&gt;2–5 seconds per query&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;That is why a store feels fine with 100 products and crawls with 2,000. Nothing "broke". The table just grew, and every unindexed lookup grew with it.&lt;/p&gt;

&lt;p&gt;Notice the contrast: finding a product's featured image is fast, because &lt;code&gt;_thumbnail_id&lt;/code&gt; is looked up by meta_key — and meta_key &lt;em&gt;has&lt;/em&gt; an index. The moment a query filters by value, the index is gone.&lt;/p&gt;

&lt;h2&gt;
  
  
  WooCommerce already knows this
&lt;/h2&gt;

&lt;p&gt;This is exactly why WooCommerce built the &lt;code&gt;wc_product_meta_lookup&lt;/code&gt; table — a purpose-built table with proper indexes for price, SKU, stock and ratings lookups — and why HPOS (High-Performance Order Storage) moves orders out of wp_posts/wp_postmeta entirely.&lt;/p&gt;

&lt;p&gt;Those features exist because the default table design does not scale.&lt;/p&gt;

&lt;h2&gt;
  
  
  What you can actually do
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;1. Clean the table first&lt;/strong&gt;&lt;br&gt;
Orphaned postmeta rows (from deleted products), old revision data and leftover plugin rows inflate the table. Removing them shrinks every scan.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Add the missing index — carefully&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;ALTER&lt;/span&gt; &lt;span class="k"&gt;TABLE&lt;/span&gt; &lt;span class="n"&gt;wp_postmeta&lt;/span&gt; &lt;span class="k"&gt;ADD&lt;/span&gt; &lt;span class="k"&gt;INDEX&lt;/span&gt; &lt;span class="n"&gt;meta_value_idx&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;meta_value&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;191&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;One honest caveat: a prefix index helps exact and prefix matches. It cannot help a &lt;code&gt;LIKE '%term%'&lt;/code&gt; search — a leading wildcard still scans. Know which queries you actually run before expecting miracles.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. Use the built-in escapes&lt;/strong&gt;&lt;br&gt;
Keep WooCommerce's product lookup tables regenerated, and move to HPOS if your store qualifies. These were built for precisely this problem.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4. Measure, don't guess&lt;/strong&gt;&lt;br&gt;
Run &lt;code&gt;EXPLAIN&lt;/code&gt; on the exact query WP_Query generates, and use Query Monitor to see which lookups fire on your busiest pages and how long they take.&lt;/p&gt;

&lt;h2&gt;
  
  
  The takeaway
&lt;/h2&gt;

&lt;p&gt;wp_postmeta is not slow because WordPress is slow. It is slow because one heavily-queried column was never given an index — and the cost only shows up when your store succeeds and grows.&lt;/p&gt;

&lt;p&gt;Have you ever opened wp_postmeta on a big store and checked its size? How many rows did you find?&lt;/p&gt;




&lt;p&gt;&lt;em&gt;I'm Abdullah — a WordPress, Elementor &amp;amp; WooCommerce developer. I build business websites, online stores, and custom plugins &amp;amp; themes when no ready-made solution exists.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Portfolio: &lt;a href="https://abdullahwebdev.blogspot.com/" rel="noopener noreferrer"&gt;https://abdullahwebdev.blogspot.com/&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;

</description>
      <category>wordpress</category>
      <category>woocommerce</category>
      <category>mysql</category>
      <category>php</category>
    </item>
  </channel>
</rss>
