Skip to content
WordPress.org
  • Showcase
  • Plugins
  • Themes
  • Hosting
  • News
    • Learn WordPress
    • Documentation
    • Education
    • Forums
    • Developers
    • Blocks
    • Patterns
    • Photos
    • Openverse ↗︎
    • WordPress.tv ↗︎
    • About WordPress
    • Make WordPress
    • Events
    • Five for the Future
    • Enterprise
    • Gutenberg ↗︎
    • Job Board ↗︎
  • Merch ↗︎
  • Get WordPress
Get WordPress
WordPress.org

Plugin Directory

SpeedUp Meta Tables

  • Submit a plugin
  • My favorites
  • Log in
  • Submit a plugin
  • My favorites
  • Log in

SpeedUp Meta Tables

By Orçun Candan
Download
  • Details
  • Reviews
  • Installation
  • Development
Support

Description

WordPress keeps custom fields as rows: one row per object, field and value. Filter a product list by supplier and sort it by cost, and MySQL joins that table once per field, over millions of rows. On a large WooCommerce store such admin screens take seconds.

SpeedUp Meta Tables watches the meta queries your site runs, builds a narrow table for the ones that keep coming back, and answers them from it, with the same results. Your data and every write stay exactly where WordPress puts them.

Results on a test store

25,000 products, 49,000 variations, 48,000 customers, 60,000 orders, about 4 million postmeta rows. 43 WooCommerce admin screens and jobs, each run with and without the plugin.

  • Meta SQL per screen: 99 ms to 0.66 ms at the median, 149 times faster. “Products without an image” went from 3.1 s to 3.4 ms, “customers without a company name” from 1.1 s to 0.6 ms.
  • Pages slower than one second: 13 to 0.
  • Four people in the admin at once: 87 pages served in 45 seconds without the plugin, 277 with it.
  • Same results, checked row by row: 154 queries and 855 comparisons after real product, order and stock changes, 0 differences.

Every screen, the method, the scripts and the raw numbers: benchmark on GitHub.

How it works

  1. It watches. On admin screens every request, on the front end one in ten: each meta query it cannot answer yet is reduced to its shape (which fields, operators, sort and post type). Values and search terms are not stored.
  2. It builds. Once an hour it builds a table for each shape seen 20 times on a type with at least 1,000 objects: one row per object, one column per field, and the indexes that query needs. “Build now” does it right away.
  3. It answers. In the query filter of wpdb it recognizes the shape and reads the narrow table instead. Anything it does not fully understand goes to WordPress unchanged.
  4. It follows writes. Writes go to the meta tables as always. The plugin notes which objects changed and copies them before the next read that needs them.
  5. It cleans up. Tables whose queries have not been seen for 30 days are dropped.

Where it helps

  • Product, order, coupon and customer lists filtered or sorted by custom fields, whether the filter comes from WooCommerce, another plugin or your own code, as long as it goes through WP_Query, WP_User_Query or wc_get_orders().
  • “Has no value” filters (NOT EXISTS), numeric sorts on text fields and counts, which indexes on the meta table do not help.
  • WooCommerce’s low stock counter and report, the scheduled sale job, customer totals, order search in both the HPOS tables and the posts table.
  • REST API product filters and WP_User_Query lists by role or field.

It does not speed up pages without meta filters, and it builds nothing for types with fewer than 1,000 objects.

What it never does

  • It never changes how WordPress, WooCommerce or another plugin writes. Its tables only hold copies.
  • It never edits another plugin’s code or changes its behavior. It works through WordPress hooks only.
  • It never sends data anywhere: no external requests, no tracking.
  • When it is not sure (SQL it cannot read, a write it could not follow, a table being rebuilt) the query runs exactly as WordPress wrote it.

Requirements

  • MySQL 8.0.13 or newer. MariaDB is not supported yet; the plugin stays idle there.
  • No database drop-in that spreads queries over several connections or another database (HyperDB, LudicrousDB, the SQLite integration). Query Monitor’s drop-in is fine.
  • On multisite, activate it per site; network activation is refused.
  • The database user may create, alter and drop tables.
  • WP-Cron, or a system cron that calls it, for the hourly check.

Privacy

The plugin stores copies of your own meta values in your own database, and the shape of the queries it saw without their values. Nothing leaves your server.

Screenshots

Tools > SpeedUp Meta Tables on the test store after the plugin built its tables: the state, the buttons, and the tables with the fields each one holds.
Tools > SpeedUp Meta Tables on the test store after the plugin built its tables: the state, the buttons, and the tables with the fields each one holds.
The query patterns it recorded. Values and search terms are not stored, only which fields, operators and sort a query uses.
The query patterns it recorded. Values and search terms are not stored, only which fields, operators and sort a query uses.
Meta SQL time of 39 WooCommerce admin screens on the test store, without the plugin (orange) and with it (blue). Log scale; the right column is how many times faster.
Meta SQL time of 39 WooCommerce admin screens on the test store, without the plugin (orange) and with it (blue). Log scale; the right column is how many times faster.

Installation

  1. Install and activate the plugin.
  2. Open the admin screens your team uses, as usual. Tools > SpeedUp Meta Tables lists the query patterns it saw.
  3. Press “Build now”, or wait for the hourly check. The same page then lists the tables it built. From WP-CLI: wp speedup-meta build.

FAQ

How soon does it help?

Right after “Build now”. Without it, the hourly check builds a table once a query has been seen 20 times. Building took about two minutes for the whole test store; meanwhile queries go to WordPress as usual.

What happens to my data when I deactivate or delete the plugin?

Nothing. The plugin’s tables only hold copies. Deactivating drops the copies, since they would go stale without the plugin watching writes. Deleting also removes the plugin’s options and its record of the queries it saw.

Does it slow down writes?

Slightly. After a write to a watched object, one small row is noted (about 0.04 ms). The next read that needs that object copies it first: about 5 ms for one product.

What does it cost?

Disk space: 245 MB on the test store, next to 778 MB of meta tables. Each request that reads meta loads the table definitions once, about 0.3 ms. Both are included in the results above.

Does it work with WooCommerce HPOS?

Yes. It answers order queries on the HPOS tables (wc_orders_meta) and on the older posts table.

Another program writes to the database directly.

The plugin only sees writes that go through WordPress’ wpdb. After direct writes, run wp speedup-meta repair: it compares every copied object with the meta tables and fixes the differences (about two minutes for 267,000 objects on the test store). While it runs, reads go to WordPress.

Query Monitor shows different SQL.

Yes. $wpdb->last_query and Query Monitor show the SQL the plugin ran instead. When several rows have the same sort value, their order can differ from WordPress’ order, as it can between two MySQL versions.

Can I turn it off for one request?

Add a filter from a plugin or a mu-plugin: add_filter( 'speedup_meta_tables_enabled', '__return_false' );. Writes are still noted, so the tables stay correct. The Pause button turns answering off for the whole site.

Reviews

There are no reviews for this plugin.

Contributors & Developers

“SpeedUp Meta Tables” is open source software. The following people have contributed to this plugin.

Contributors
  • Orçun Candan

Translate “SpeedUp Meta Tables” into your language.

Interested in development?

Browse the code, check out the SVN repository, or subscribe to the development log by RSS.

Changelog

0.1.2

  • Admin screens are watched on every request, so slow admin filters are learned after a few visits instead of weeks.
  • “Build now” and wp speedup-meta build build tables for every query pattern seen so far; the hourly check keeps them.
  • The hourly check builds a table after 20 sightings of a pattern (was 50).

0.1.1

  • The table definitions are kept in the plugin’s own table; the autoloaded copy is written only through the Options API.

0.1.0

  • First release, on GitHub.

Meta

  • Version 0.1.2
  • Last updated 2 days ago
  • Active installations Fewer than 10
  • WordPress version 6.4 or higher
  • Tested up to 7.1.5
  • PHP version 8.0 or higher
  • Tags
    custom fieldsdatabaseperformancepostmetawoocommerce
  • Advanced View

Ratings

No reviews have been submitted yet.

Your review

See all reviews

Contributors

  • Orçun Candan

Support

Got something to say? Need help?

View support forum

  • About
  • News
  • Hosting
  • Privacy
  • Showcase
  • Themes
  • Plugins
  • Patterns
  • Learn
  • Documentation
  • Developers
  • WordPress.tv ↗
  • Get Involved
  • Events
  • Donate ↗
  • Merch ↗
  • WordPress.com ↗
  • Matt ↗
  • bbPress ↗
  • BuddyPress ↗
WordPress.org

The WordPress® trademark is the intellectual property of the WordPress Foundation.

  • Visit our X (formerly Twitter) account
  • Visit our Bluesky account
  • Visit our Mastodon account
  • Visit our Threads account
  • Visit our Facebook page
  • Visit our Instagram account
  • Visit our LinkedIn account
  • Visit our TikTok account
  • Visit our YouTube channel
  • Visit our Tumblr account
Code is Poetry