Performance Gains of Relational DB Setup

I can’t comment on foreign keys but moving to InnoDB would be a good idea for large scale. Although it’s a little slower than MyISAM, it does row level locking, rather than table level locking. As a result saving a post or doing a lengthy operation or query won’t lock the posts table, freezing the … Read more

WordPress Connection Pooling

If you just add p: then it conflicts with MySQL Port. So wp-config.php file you should be able to do it by replacing define(‘DB_HOST’,’localhost’); with define(‘DB_HOST’,’p:localhost:3306′);

Ordering posts by day (not time) AND meta value

This is what I’ve found. I’m using a filter to filter the ORDER BY on the SQL query generated by WP_Query. The filter is this posts_orderby. And with it, you can write a custom ORDER BY for the query. I’m gonna show you an example. add_filter(‘posts_orderby’, ‘posts_orderby’); function posts_orderby($orderby_for_query) { $orderby_for_query = “LEFT(wp_posts.post_date, 10) DESC, … Read more

SQL select of users by metadata

Double-check your SQL syntax. It sounds like you want to do a JOIN … But you’re not building the query correctly. It should be something more like: SELECT u.ID, u.user_login, u.user_nicename, u.user_email FROM $wpdb->users u INNER JOIN $wpdb->usermeta m ON m.user_id = u.ID WHERE m.meta_key = ‘wp_capabilities’ AND m.meta_value LIKE ‘%supplier%’ ORDER BY u.user_registered You … Read more

$wpdb and MySQL Create Trigger

In the question you linked to, the solution was to use mysqli_multi_query as the API for executing the SQL. $wpdb desen’t have an API to do a multi query therefor you can’t use it directly, but you can get the handle to the mysql interface from $wpdb->dbh and do something like $sql_trigger = “….”; mysqli_multi_query($wpdb->dbh,$sql_trigger);