Slow Mysql Queries

WP options (which is one of the most basic and used storage APIs) can be stored with or without “autoload” setting. Usually this is reasonable, since many options will be checked on each and every page load, so loading them in bulk during core load is much more efficient than individually. Problems usually start when … Read more

How to add and SQL query of posts only published

You should be able to get away with just adding AND $wpdb->posts.post_status=”publish” at the end. $prepare_string = ” SELECT DISTINCT ID FROM $wpdb->posts LEFT JOIN $wpdb->postmeta ON ( $wpdb->posts.ID = $wpdb->postmeta.post_id ) LEFT JOIN $wpdb->postmeta AS mt1 ON ( $wpdb->posts.ID = mt1.post_id ) WHERE ( ( $wpdb->postmeta.meta_key = ‘event_date’ AND $wpdb->postmeta.meta_value >= %d ) OR … Read more

wp_admin edit.php slow with lots of queries

One way to do this (and yes, it is ugly and hackish) is to create a custom page having a custom page template that draws out all of your posts and creates the proper admin url links for each one. For example: <?php /* Template Name: View Posts Quickly */ if ( !is_user_logged_in() ) { … Read more

How to check for empty and not a failure

You test for a fail by explicitly testing for false: if (null === $mypostids) { /* it failed */ } NB: three equals signs! you want to check for identical, not just equivalent edit: originally said false, changed to null after looking at get_result() function in source.

Concurrent / simultaneous MySQL connections

IMHO that would depend on the hosting company and what resources you are limited to. Let’s say you pick Amazon’s MySQL RDS. There are seven server models permitted. Each model allows a maximum value for the number of connections. I wrote a post about this last month in the DBA StackExchanage : Should I increase … Read more