axelerant / testimonials-widget

Easily add social proofing to your website with Testimonials Widget. List or slide reviews via functions, shortcodes, or widgets.
http://wordpress.org/plugins/testimonials-widget/
GNU General Public License v2.0
10 stars 7 forks source link

Too many queries on /wp-admin/ load #173

Closed michael-cannon closed 9 years ago

michael-cannon commented 9 years ago

WPEngine support engineers rock!

https://help.wpengine.com/requests/356038


Jeffrey Hogan, Mar 23, 3:58 PM: Howdy Michael,

I checked over the query output Trey mentioned in his last reply and compiled a list of queries for the information requested. With the most recent report, the testimonials-widget-premium plugin was down to 236 queries out of 249 total queries across all plugins. Ultimately, it looks like only one type of query in particular was responsible for the vast majority of database hits:

$ 212 SELECT post_id, meta_key, meta_value FROM wp_postmeta WHERE post_id IN (####) ORDER BY meta_id ASC In the above line '####' is something I added for counting purposes as a placeholder. That '####' field was typically just one ID as opposed to what you would typically expect when using WHERE ... IN, a list of values. So my best guess is there is a set of queries that were intended to select multiple rows in just one query that instead got broken out into a large amount of individual queries. The 212 at the start of that line refers to 212 queries of that nature found in the most recent report generated by our tool. I did notice a few other queries that popped up a bit. E.g., something along the lines of SELECT * FROM wp_posts WHERE = 17417 LIMIT 1 popped up ~10 times. However no other set of queries were hit anywhere near as much as the select from wp_postmeta query mentioned above. For a bit more context, here is the full "stack trace" surrounding a particular instance of that query:

SELECT post_id, meta_key, meta_value FROM wp_postmeta WHERE post_id IN (1014287) ORDER BY meta_id ASC Source: /nas/wp/www/cluster-40089/axelerant/wp-content/plugins/testimonials-widget-premium/includes/class-testimonials-widget-premium.php:1880

Backtrace: require('wp-blog-header.php'), require_once('wp-includes/template-loader.php'), include('/themes/salient-child/template-home-3.php'), get_footer, locate_template, load_template, require_once('/themes/salient-child/footer.php'), dynamic_sidebar, call_user_func_array, WP_Widget->display_callback, Aihrus_Widget->widget, Testimonials_Widget_Slider_Widget::get_content, Testimonials_Widget::testimonials_slider, Testimonials_Widget::get_testimonials_html, Testimonials_Widget::get_testimonial_html, Testimonials_Widget::get_schema, apply_filters('tw_schema_review'), call_user_func_array, Testimonials_Widget_Premium::schema_review, Testimonials_Widget_Premium::get_aggregate_rating_value, Testimonials_Widget_Premium::get_aggregate_rating_count, get_post_meta, get_metadata, update_meta_cache Every other query of this type that I checked was coming from line 1880 of the class-testimonials-widget-premium.php script as well. For the sake of completeness, I've attached a text file with a full list of query counts. In that data, the number on the left lists the total occurrences.

I hope the above details help in tracking down the performance issues being seen and if there is any other information or issue I can assist with, please just let me know!

Regards, Jeffrey Hogan | Customer Specialist WP Engine - Finely Tuned WordPress

michael-cannon commented 9 years ago

query log


1 SELECT * FROM wp_posts WHERE = 1014332 LIMIT 1 1 SELECT * FROM wp_posts WHERE = 1014669 LIMIT 1 1 SELECT * FROM wp_posts WHERE = 131266 LIMIT 1 1 SELECT * FROM wp_posts WHERE = 15219 LIMIT 1 1 SELECT * FROM wp_posts WHERE = 15898 LIMIT 1 1 SELECT * FROM wp_posts WHERE = 17417 LIMIT 1 1 SELECT * FROM wp_posts WHERE = 17877 LIMIT 1 1 SELECT * FROM wp_posts WHERE = 20334 LIMIT 1 1 SELECT SQL_CALC_FOUND_ROWS wp_posts.ID FROM wp_posts WHERE 1=1 AND wp_posts.post_type = 'testimonials-widget' AND ((wp_posts.post_status = 'publish' OR wp_posts.post_status = 'private')) ORDER RAND() LIMIT 0, 10 1 SELECT option_value FROM wp_options WHERE = '_wp_sessiond1541f7799768aa29abb6d73dee86452' LIMIT 1 1 SELECT t., tt._, tr.object_id FROM wp_terms AS t INNER JOIN wp_term_taxonomy AS tt ON tt.term_id = t.term_id INNER JOIN wp_term_relationships AS tr ON tr.term_taxonomy_id = tt.term_taxonomy_id WHERE tt.taxonomy IN ('category', 'post_tag') AND tr.object_id IN (14455, 14468, 14491, 15897, 17523, 17875, 20333, 131216, 1014129, ORDER BY t.name ASC 1 SELECT wp_posts.* FROM WHERE ID IN (131216,17875,14468,15897,14491,20333,1014204,17523,14455,1014129) 1 SELECT wp_posts.* FROM wp_posts INNER JOIN wp_postmeta ON ( wp_posts.ID = wp_postmeta.post_id ) INNER JOIN wp_postmeta AS mt1 ON ( wp_posts.ID = mt1.post_id ) WHERE 1=1 AND wp_posts.post_type = 'testimonials-widget' AND (wp_posts.post_status = 'publish' OR wp_posts.post_status = 'refunded' OR wp_posts.post_status = 'failed' OR wp_posts.post_status = 'revoked' OR wp_posts.post_status = 'abandoned' OR wp_posts.post_status = 'active' OR wp_posts.post_status = 'inactive') AND ( ( wp_postmeta.meta_key = 'testimonials-widget-item' AND CAST(wp_postmeta.meta_value AS CHAR) LIKE '%Michael Cannon%' ) AND mt1.meta_key = 'testimonials-widget-rating' ) GROUP BY ORDER BY wp_posts.post_date DESC 1 SELECT wp_posts.* FROM wp_posts INNER JOIN wp_postmeta ON ( wp_posts.ID = wp_postmeta.post_id ) INNER JOIN wp_postmeta AS mt1 ON ( wp_posts.ID = mt1.post_id ) WHERE 1=1 AND wp_posts.post_type = 'testimonials-widget' AND (wp_posts.post_status = 'publish' OR wp_posts.post_status = 'refunded' OR wp_posts.post_status = 'failed' OR wp_posts.post_status = 'revoked' OR wp_posts.post_status = 'abandoned' OR wp_posts.post_status = 'active' OR wp_posts.post_status = 'inactive') AND ( ( wp_postmeta.meta_key = 'testimonials-widget-item' AND CAST(wp_postmeta.meta_value AS CHAR) LIKE '%Testimonials Widget Premium Plugin for WordPress%' ) AND mt1.meta_key = 'testimonials-widget-rating' ) GROUP BY ORDER BY wp_posts.post_date DESC 1 SELECT wp_posts.* FROM wp_posts INNER JOIN wp_postmeta ON ( wp_posts.ID = wp_postmeta.post_id ) WHERE 1=1 AND wp_posts.post_type = 'testimonials-widget' AND (wp_posts.post_status = 'publish' OR wp_posts.post_status = 'refunded' OR wp_posts.post_status = 'failed' OR wp_posts.post_status = 'revoked' OR wp_posts.post_status = 'abandoned' OR wp_posts.post_status = 'active' OR wp_posts.post_status = 'inactive') AND ( ( wp_postmeta.meta_key = 'testimonials-widget-item' AND CAST(wp_postmeta.meta_value AS CHAR) LIKE '%Michael Cannon – Full Stack Developer%' ) ) GROUP BY ORDER BY wp_posts.post_date DESC 1 SELECT wp_posts.* FROM wp_posts INNER JOIN wp_postmeta ON ( wp_posts.ID = wp_postmeta.post_id ) WHERE 1=1 AND wp_posts.post_type = 'testimonials-widget' AND (wp_posts.post_status = 'publish' OR wp_posts.post_status = 'refunded' OR wp_posts.post_status = 'failed' OR wp_posts.post_status = 'revoked' OR wp_posts.post_status = 'abandoned' OR wp_posts.post_status = 'active' OR wp_posts.post_status = 'inactive') AND ( ( wp_postmeta.meta_key = 'testimonials-widget-item' AND CAST(wp_postmeta.meta_value AS CHAR) LIKE '%Michael Cannon%' ) ) GROUP BY ORDER BY wp_posts.post_date DESC 1 SELECT wp_posts.* FROM wp_posts INNER JOIN wp_postmeta ON ( wp_posts.ID = wp_postmeta.post_id ) WHERE 1=1 AND wp_posts.post_type = 'testimonials-widget' AND (wp_posts.post_status = 'publish' OR wp_posts.post_status = 'refunded' OR wp_posts.post_status = 'failed' OR wp_posts.post_status = 'revoked' OR wp_posts.post_status = 'abandoned' OR wp_posts.post_status = 'active' OR wp_posts.post_status = 'inactive') AND ( ( wp_postmeta.meta_key = 'testimonials-widget-item' AND CAST(wp_postmeta.meta_value AS CHAR) LIKE '%TYPO3 Importer for WordPress%' ) ) GROUP BY ORDER BY wp_posts.post_date DESC 1 SELECT wp_posts.* FROM wp_posts INNER JOIN wp_postmeta ON ( wp_posts.ID = wp_postmeta.post_id ) WHERE 1=1 AND wp_posts.post_type = 'testimonials-widget' AND (wp_posts.post_status = 'publish' OR wp_posts.post_status = 'refunded' OR wp_posts.post_status = 'failed' OR wp_posts.post_status = 'revoked' OR wp_posts.post_status = 'abandoned' OR wp_posts.post_status = 'active' OR wp_posts.post_status = 'inactive') AND ( ( wp_postmeta.meta_key = 'testimonials-widget-item' AND CAST(wp_postmeta.meta_value AS CHAR) LIKE '%Testimonials Widget Premium Plugin for WordPress%' ) ) GROUP BY ORDER BY wp_posts.post_date DESC 1 SELECT wp_posts.* FROM wp_posts INNER JOIN wp_postmeta ON ( wp_posts.ID = wp_postmeta.post_id ) WHERE 1=1 AND wp_posts.post_type = 'testimonials-widget' AND (wp_posts.post_status = 'publish' OR wp_posts.post_status = 'refunded' OR wp_posts.post_status = 'failed' OR wp_posts.post_status = 'revoked' OR wp_posts.post_status = 'abandoned' OR wp_posts.post_status = 'active' OR wp_posts.post_status = 'inactive') AND ( ( wp_postmeta.meta_key = 'testimonials-widget-item' AND CAST(wp_postmeta.meta_value AS CHAR) LIKE '%Website Support Agreement by Aihrus%' ) ) GROUP BY ORDER BY wp_posts.post_date DESC 2 SELECT post_name FROM wp_posts WHERE post_name = 'testimonial' AND = 0 LIMIT 1 2 SELECT post_name FROM wp_posts WHERE post_name = 'testimonials-archive' AND = 0 LIMIT 1 212 SELECT post_id, meta_key, meta_value FROM wp_postmeta WHERE post_id IN (####) ORDER BY meta_id ASC

michael-cannon commented 9 years ago

SCALING WORDPRESS FOR HIGH TRAFFIC pdf rocks for tips on performance issues!

michael-cannon commented 9 years ago

Worked through tips above and fixed the slug checker on TW