e107inc / e107

e107 Bootstrap CMS (Content Management System) v2 with PHP, MySQL, HTML5, jQuery and Twitter Bootstrap. Issue Discussion Room: https://gitter.im/e107inc/e107
https://e107.org
GNU General Public License v3.0
321 stars 213 forks source link

Query time #3138

Closed Evgura closed 6 years ago

Evgura commented 6 years ago

Why such a long query time? How can I reduce it?
E107 Dev.

23) Query: [Main Page Body - /home/admin/web/site.ru/public_html/e107_handlers/model_class.php(3383)]SELECT COUNT(n.news_id) AS category_news_count, nc.* FROM e107_news_category AS nc LEFT JOIN e107_news AS n ON n.news_category=nc.category_id WHERE n.news_class REGEXP '(^|,)(3|2|1|4|253|254|250|251|0)(,|$)' AND NOT (n.news_class REGEXP '(^|,)(255)(,|$)') AND n.news_start < 1526938752 AND (n.news_end=0 || n.news_end>1526938752) GROUP BY nc.category_id ORDER BY nc.category_order ASC

id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra 1 | SIMPLE | nc | ALL | PRIMARY |   |   |   | 3 | Using temporary; Using filesort 1 | SIMPLE | n | ref | news_category,news_start_end | newscategory | 1 | admin*.nc.category_id | 101 | Using where Query time: 4.5650** (ms)

25) Query: [Main Page Body - /home/admin/web/site.ru/public_html/e107_handlers/model_class.php(3383)]SELECT SQL_CALC_FOUND_ROWS n.*, u.user_id, u.user_name, u.user_customtitle, u.user_image, nc.category_id, nc.category_name, nc.category_sef, nc.category_icon FROM e107_news AS n LEFT JOIN e107_user AS u ON n.news_author = u.user_id LEFT JOIN e107_news_category AS nc ON n.news_category = nc.category_id WHERE FIND_IN_SET(0, n.news_render_type) AND n.news_start < 1526938752 AND (n.news_end=0 || n.news_end>1526938752) AND n.news_class REGEXP '(^|,)(3|2|1|4|253|254|250|251|0)(,|$)' AND NOT (n.news_class REGEXP '(^|,)(255)(,|$)') ORDER BY n.news_sticky DESC, n.news_datestamp DESC LIMIT 10

id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra 1 | SIMPLE | n | ALL | news_start_end |   |   |   | 316 | Using where; Using filesort 1 | SIMPLE | u | eqref | PRIMARY | PRIMARY | 4 | admin.n.news_author | 1 |   1 | SIMPLE | nc | eqref | PRIMARY | PRIMARY | 1 | admin.n.news_category | 1 |   Query time: 6.7539 (ms)

CaMer0n commented 6 years ago

@Evgura What URL are you loading?

Evgura commented 6 years ago

This is the main page of the site. The theme of the website BS_Magazine_01. Or need a specific website address?

CaMer0n commented 6 years ago

Thank you @Evgura ! And if you switch your theme to "bootstrap 3" does it speed things up?

Evgura commented 6 years ago

With the theme "bootstrap 3" - CMS 2.1.8 GitHub

16) Query: [Start regular eFront Class - /home/admin/web/site.ru/public_html/e107_plugins/news/news.php(98)]SELECT SQL_CALC_FOUND_ROWS n.*, u.user_id, u.user_name, u.user_customtitle, u.user_image, nc.category_id, nc.category_name, nc.category_sef, nc.category_icon, nc.category_meta_keywords, nc.category_meta_description, nc.category_template FROM e107_news AS n LEFT JOIN e107_user AS u ON n.news_author = u.user_id LEFT JOIN e107_news_category AS nc ON n.news_category = nc.category_id WHERE n.news_class REGEXP '(^|,)(3|2|1|4|253|254|250|251|0)(,|$)' AND NOT (n.news_class REGEXP '(^|,)(255)(,|$)') AND n.news_start < 1527271637 AND (n.news_end=0 || n.news_end>1527271637) AND (FIND_IN_SET('0', n.news_render_type) OR FIND_IN_SET(1, n.news_render_type)) ORDER BY n.news_sticky DESC, news_datestamp DESC LIMIT 0,10

id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra 1 | SIMPLE | n | ALL | news_start_end |   |   |   | 316 | Using where; Using filesort 1 | SIMPLE | u | eqref | PRIMARY | PRIMARY | 4 | admin.n.news_author | 1 |   1 | SIMPLE | nc | eqref | PRIMARY | PRIMARY | 1 | admin.n.news_category | 1 |   Query time: 4.7240 (ms)

20) Query: [Main Page Body - /home/admin/web/site.ru/public_html/e107_handlers/sitelinks_class.php(1670)]SELECT * FROM e107_links WHERE link_category = 1 AND ((link_class >= 0 AND link_class IN (3,2,1,4,253,254,250,251,0)) OR (link_class < 0 AND ABS(link_class) NOT IN (3,2,1,4,253,254,250,251,0)) ) ORDER BY link_order,link_parent ASC

id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra 1 | SIMPLE | e107_links | ALL |   |   |   |   | 271 | Using where; Using filesort Query time: 1.9619 (ms)

CaMer0n commented 6 years ago

That's 4.7 1000ths of a second. Do you think you'll perceive a difference if it is faster? Perhaps your page delays are coming from elsewhere?

Moc commented 6 years ago

@Evgura Any feedback on Cameron's reply? It seems that the loading times you show are not out of the ordinary. Did you try running the time analysis?

?[debug=time+]

Evgura commented 6 years ago

Normally works on time, all well.