TagPerformance

Interesting WordPress Performance Tweaks

Over the course of a couple of days, the speed of loading a new post form (like the one I’m typing in right now) has been kind of sluggish. Multiple second load times and kind of sluggish responsiveness was bugging me, but I’m not in the new post that often.

While reading up on some good WordPress habits, like Core Functionality Plugins. I noticed a bug posted that hasn’t really been fixed in several years. Basically: WordPress, on the new post page, makes a really slow query for these old Custom Fields that aren’t used in many new posts. The queries run can take make the new post page take several seconds (15+!) on large sites.

The fix is surprisingly easy:

/**
 * Remove Ancient Custom Fields metabox from post editor
 * because it uses a very slow query meta_key sort query
 * so on sites with large postmeta tables it is super slow
 * and is rarely useful anymore on any site
 */
function s9_remove_post_custom_fields_metabox() {
     foreach ( get_post_types( '', 'names' ) as $post_type ) {
         remove_meta_box( 'postcustom' , $post_type , 'normal' );   
     }
}
add_action( 'admin_menu' , 's9_remove_post_custom_fields_metabox' ); 

Add that to a custom plugin, or Code Snippets and boom, much faster loading times for new posts.

Performance Enhancers

With a bit of tweaking and some fixing up of the default nginx configuration on my host, I’ve finally hit very good performance metrics. Though I can’t imagine it’d behave this way under any serious load.

Hooray!

© 2020 Verily

Theme by Anders NorénUp ↑