I have a 2GB WordPress database (using InnoDB Storage Engine) and I noticed my site loads slow when I press the publish button right after I selected a featured image in the media library.
I had a look at my tables and noticed wp_postmeta
is the biggest table and wp_posts
the 2nd biggest out of all the tables.
Is there a way to speed up my load? The database is InnoDB
DISCLAIMER : Not a WordPress Developer, Just a MySQL DBA
There is a special table structure in Oracle called a Materialized View. Basically, it is built by performing a JOIN query (using no WHERE clause) and storing the result set. Then, simply SELECT from that static result set rather than rebuilding each JOIN result.
First, let’s look at the two tables:
wp_postmeta
wp_posts
This may sound rather ugly in the database world, but what is needed would be a Cartesian Product that would be manifested as a regular table.
Brace yourself, this is going to be rather disturbing…
Basically, everything and the kitchen sink is in this table. You would use this table to run your SELECT queries. Any query not perform well? Just add the needed index into the script and rebuild it.
CAVEAT #1
This process would be worthwhile as long as the table can be rebuilt during off-hours and made available before the business day begins. You can make the old copy available during the rebuild process by running like this:
CAVEAT #2
The table
wp_posts_postmeta_joined
should be MyISAM regardless of the storage engines used bywp_posts
andwp_postmeta
.I added
ROW_FORMAT=Fixed
to increase the table read speed 20-25%. This table can be rather large, so make sure you have the diskspace. I wrote about this back on Mar 25, 2011.Give it a Try !!!