Changing BIGINT to INT

There should not be any downside. The user ID is cast to int in many places in the WP PHP files anyway. But I don’t think this is a real performance problem. If your queries are slow, it might be more useful to inspect each of them and look for opportunities to improve the queries … Read more

Large database causes slow load

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, … Read more

meta_query on a date range using an array of values

I needed to get post with type event and the custom field “date” later than today, this sample of code worked perfectly for me, I hope it helps to someone in a similar situation. $today = date(“Y-m-d”); $today1 = date(“Ymd”, strtotime(“$today”)); $custom_meta = array( array( ‘key’ => ‘data_de_inicio’, ‘value’=>$today1, ‘compare’=>’>’, ‘type’=>’date’, ), ); $query = … Read more

Order By Multiple Meta Fields

One problem with the query is that the self-join with the ambiguous WHERE gives you a crossed dataset (which is masked by the DISTINCT), so it would be simpler to use wp_post as a base to attach the joins that precisely match the keys, eg SELECT p.ID, key1.meta_value as prog_ongoing, key2.meta_value as prog_date_start FROM $wpdb->posts … Read more

the_author_meta not working

It’s entirely possible that you are calling the_author_meta() from outside of your post loop in the author.php template in which case the above will not work. Instead, you can use get_the_author_meta(‘facebook’) or… get_the_author_meta(‘facebook’, $user_id) where $user_id is the ID# of the current user/author. To get the user ID you can do this; <div class=”user_social_icons”> <a … Read more

Universal problem: first request after ~25 second inactivity always slower (~1 second) than subsequent requests (~1/10sec)

Without looking at your box to see exactly what’s going on, here are some potential avenues of slowness: Potential Causes Apache Apache is usually configured in such a way that a single httpd process is always running in the background. When a request comes in over the wire, it spins up a new httpd process … Read more

WooCommerce – Query for ordered products

Fixed query select p.ID as order_id, p.post_date, i.order_item_name, max( CASE WHEN im.meta_key = ‘_product_id’ and i.order_item_id = im.order_item_id THEN im.meta_value END ) as Prod_ID from wp_posts as p, wp_postmeta as pm, wp_woocommerce_order_items as i, wp_woocommerce_order_itemmeta as im where p.post_type=”shop_order” and p.ID = pm.post_id and p.ID = i.order_id and p.post_date BETWEEN ‘2016-01-14 00:00:00’ AND ‘2016-01-14 23:59:59’ … Read more