Relationship between performance and database size

A bigger database isn’t per definition slower, and a smaller database isn’t per definition faster. When a table contains a large amount of information, it could take longer for queries to get their results, depending on the type of query, the amount of data you want to return, the table structure attributes, types and indexes. … 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

PHP variable in WordPress database query

The WPDB prepare method is what you’re after, as this will prep your data for passing to a query and also ensure data matches the type its intended to be whilst also handling quoting where necessary at the same time. Fixing your code could be a matter of.. $voucher=”MK0186″; $is_in_database = $wpdb->get_results( “SELECT * FROM … Read more

WordPress Backup

There’s 2 steps required to take a full backup. Backup your content Backup your files Backup Content To backup your content, you can use the WordPress export tool. Or you can take a database dump or export copy of your database directly from phpMyAdmin which is the best method. Another way to backup your content … Read more

Cannot unserialize WordPress serialized values in `wp_options` table?

Your problem is that serialized strings contains escape slashes that are not evaluated as such, because the wrapping quote is a single quote. You are using: $v = ‘a:2:{i:0;b:0;s:8:\”auto_add\”;a:0:{}}’; // wrong You have to use either $v = “a:2:{i:0;b:0;s:8:\”auto_add\”;a:0:{}}”; // ok or $v = ‘a:2:{i:0;b:0;s:8:”auto_add”;a:0:{}}’; // ok By the way, you should never manually unserialize … Read more

Using posts and postmeta table to store custom Address Book Plugin data

Using posts & postmeta: There is nothing wrong in using posts and postmeta table for custom database requirements. In WordPress, although posts & postmeta table was originally there to create blog posts, later it evolved to cover many different sorts of database requirements. Using Custom Post Types, Post Meta & Custom Taxonomies, you can satisfy … Read more

prefix table and plugins

Short answer: Just a badly written plugin. Longer answer: When a plugin calls the database in the right/correct/best practice way it uses Global $wpdb instead of just naming the database table, for example: Wrong way $sql = “SELECT * FROM wp_posts WHERE… ” Right way $sql = “SELECT * FROM $wpdb->posts WHERE… ” this way … 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