Hello, I’m writing to inform you of the bad code my website crash when activate the newspaper theme.
O_O[root@site:/var/www/site/htdocs/wp-content/themes]# grep -Hr post_views_count .
./Newspaper/includes/wp_booster/td_page_views.php: static $post_view_counter_key = ‘post_views_count’;
./Newspaper/includes/wp_booster/td_page_views.php: static $post_view_counter_7_day_array = ‘post_views_count_7_day_arr’;
./Newspaper/includes/wp_booster/td_page_views.php: static $post_view_counter_7_day_total = ‘post_views_count_7_day_total’;
./Newsmag/includes/wp_booster/td_page_views.php: static $post_view_counter_key = ‘post_views_count’;
./Newsmag/includes/wp_booster/td_page_views.php: static $post_view_counter_7_day_array = ‘post_views_count_7_day_arr’;
./Newsmag/includes/wp_booster/td_page_views.php: static $post_view_counter_7_day_total = ‘post_views_count_7_day_total’;
==> mysql-slow.log <==
SET timestamp=1419544553;
SELECT SQL_CALC_FOUND_ROWS wp_posts.ID FROM wp_posts INNER JOIN wp_postmeta ON ( wp_posts.ID = wp_postmeta.post_id ) WHERE 1=1 AND wp_posts.ID NOT IN (148426,148420,148416,148424,148418,148347,148347,148359,148359,148367,148367,148337,148337,148335,148335,148001,148001,148661,148449,148447,148445,148206,148657,148652,148422,148371,148353,148685,148683,148678,148673,148643,148635,148641,148645,148622,148614,148005,148005,147353,147353,147363,147363,147362,147362,147332,147332,148606,148606,148577,148577,148549,148549,148521,148521) AND (
wp_posts.ID NOT IN (
SELECT object_id
FROM wp_term_relationships
WHERE term_taxonomy_id IN (81223)
)
) AND wp_posts.post_type = ‘post’ AND ((wp_posts.post_status = ‘publish’)) AND (
wp_postmeta.meta_key = ‘post_views_count’
) GROUP BY wp_posts.ID ORDER BY wp_postmeta.meta_value+0 DESC LIMIT 0, 6;
mysql> explain EXPLAIN SELECT SQL_CALC_FOUND_ROWS wp_posts.ID FROM wp_posts INNER JOIN wp_postmeta ON ( wp_posts.ID = wp_postmeta.post_id ) WHERE 1=1 AND wp_posts.ID NOT IN (148426,148420,148416,148424,148418,148347,148347,148359,148359,148367,148367,148337,148337,148335,148335,148001,148001,148661,148449,148447,148445,148206,148657,148652,148422,148371,148353,148685,148683,148678,148673,148643,148635,148641,148645,148622,148614,148005,148005,147353,147353,147363,147363,147362,147362,147332,147332,148606,148606,148577,148577,148549,148549,148521,148521) AND ( wp_posts.ID NOT IN ( SELECT object_id FROM wp_term_relationships WHERE term_taxonomy_id IN (81223) )
-> ) AND wp_posts.post_type = ‘post’ AND ((wp_posts.post_status = ‘publish’)) AND ( wp_postmeta.meta_key = ‘post_views_count’) GROUP BY wp_posts.ID ORDER BY wp_postmeta.meta_value+0 DESC LIMIT 0, 6;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘EXPLAIN SELECT SQL_CALC_FOUND_ROWS wp_posts.ID FROM wp_posts INNER JOIN wp_pos’ at line 1
mysql> EXPLAIN SELECT wp_posts.ID FROM wp_posts INNER JOIN wp_postmeta ON ( wp_posts.ID = wp_postmeta.post_id ) WHERE 1=1 AND wp_posts.ID NOT IN (148426,148420,148416,148424,148418,148347,148347,148359,148359,148367,148367,148337,148337,148335,148335,148001,148001,148661,148449,148447,148445,148206,148657,148652,148422,148371,148353,148685,148683,148678,148673,148643,148635,148641,148645,148622,148614,148005,148005,147353,147353,147363,147363,147362,147362,147332,147332,148606,148606,148577,148577,148549,148549,148521,148521) AND ( wp_posts.ID NOT IN ( SELECT object_id FROM wp_term_relationships WHERE term_taxonomy_id IN (81223) )
-> ) AND wp_posts.post_type = ‘post’ AND ((wp_posts.post_status = ‘publish’)) AND ( wp_postmeta.meta_key = ‘post_views_count’) GROUP BY wp_posts.ID ORDER BY wp_postmeta.meta_value+0 DESC LIMIT 0, 6;
+—-+————-+———————–+——–+————————————————————————————————–+——————+———+————————————+——–+———————————————-+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+—-+————-+———————–+——–+————————————————————————————————–+——————+———+————————————+——–+———————————————-+
| 1 | PRIMARY | wp_postmeta | ref | post_id,meta_key | meta_key | 767 | const | 111540 | Using where; Using temporary; Using filesort |
| 1 | PRIMARY | wp_posts | eq_ref | PRIMARY,type_status_date,post_parent,post_author,post_status,post_name,yarpp_title,yarpp_content | PRIMARY | 8 | electrobuzz_fm.wp_postmeta.post_id | 1 | Using where |
| 2 | SUBQUERY | wp_term_relationships | ref | PRIMARY,term_taxonomy_id | term_taxonomy_id | 8 | const | 4 | Using where; Using index |
+—-+————-+———————–+——–+————————————————————————————————–+——————+———+————————————+——–+———————————————-+
3 rows in set (0.01 sec)
There are 111540 rows accessed!
Please see attached recommendation form percona tool http://prntscr.com/83i9o1
Hello,
When active the theme Twenty Fifteen all is back to normal, when active your theme my website crash, not loading..
Have you checked that issue ?
Thank you
Hi,
Sorry for the delay!
This may happen due to the 7 days post sorting feature which makes requests to the server to update the counter and keep track of the “most popular posts”if you have it set please try without it, it will lower the number of database queries.
Let us know how it goes!
Thanks
Hi,
Have you also tried with the post view count disabled? Please do so, let us know how it goes and provide wp access via email at contact@tagdiv.com so we can have closer look at this and also provide a link to this topic.
Thanks
This slow query need to fixed.
Query
SELECT SQL_CALC_FOUND_ROWS wp_posts.ID
FROM wp_posts
WHERE 1=1
AND wp_posts.ID NOT IN (174628,174627,174629,174638,174250,174308,174155,174582,174576,174575,174579,174574,174630,174583,174404,174403,174407)
AND wp_posts.post_type = 'post'
AND ((wp_posts.post_status = 'publish'))
ORDER BY wp_posts.post_date DESC
LIMIT 0, 10
Caller
WP_Query->get_posts()+
Affected Rows
10
Time
0.1049
Please double check that.
Thank you
Hi,
We use wordpress functions like wp_query – https://codex.wordpress.org/Class_Reference/WP_Query
We don’t make direct database requests, all database requests are made via wordpress.
The requests made by the theme are fully optimized. Try to check the error.log file to see if there’s anything related to this issue.
Thank you!
-
This reply was modified 10 years by
Emil G.