• REGISTRATION REQUIREMENTS:

    Your username here MUST MATCH your XenForo username (connected to your XF license).

    Once you have registered here, then you need to start a conversation at xenforo.com w/Bob and provide the following:
    1. Your XenForo License Validation Token
    2. The Domain Name associated with the License
    NOTE: Your account will be validated once ALL requirements are verified/met. Thank you for your patience.

Future Fix Widget latest comments causes slow query

Kirby

Member
AMS Premium
CAS Premium
IMS Premium
LD Premium
RMS Premium
SC Premium
UBS Premium
UBS Version
2.3.8
XenForo Version
2.3.6
PHP Version
8.3.20
Database & Version
MariaDB 10.11.11
Are there any errors being throw?
No
Code:
SELECT `xf_xa_ubs_comment`.*, `xf_xa_ubs_blog_entry_BlogEntry_1`.*, `xf_user_User_2`.*, `xf_xa_ubs_category_Category_3`.*, `xf_xa_ubs_blog_Blog_4`.*
FROM `xf_xa_ubs_comment`
LEFT JOIN `xf_xa_ubs_blog_entry` AS `xf_xa_ubs_blog_entry_BlogEntry_1` ON (`xf_xa_ubs_blog_entry_BlogEntry_1`.`blog_entry_id` = `xf_xa_ubs_comment`.`blog_entry_id`)
LEFT JOIN `xf_user` AS `xf_user_User_2` ON (`xf_user_User_2`.`user_id` = `xf_xa_ubs_comment`.`user_id`)
LEFT JOIN `xf_xa_ubs_category` AS `xf_xa_ubs_category_Category_3` ON (`xf_xa_ubs_category_Category_3`.`category_id` = `xf_xa_ubs_blog_entry_BlogEntry_1`.`category_id`)
LEFT JOIN `xf_xa_ubs_blog` AS `xf_xa_ubs_blog_Blog_4` ON (`xf_xa_ubs_blog_Blog_4`.`blog_id` = `xf_xa_ubs_blog_entry_BlogEntry_1`.`blog_id`)
WHERE (`xf_xa_ubs_blog_entry_BlogEntry_1`.`category_id` IN (1)) AND (`xf_xa_ubs_comment`.`comment_state` = 'visible')
ORDER BY `xf_xa_ubs_comment`.`comment_date` DESC, `xf_xa_ubs_comment`.`comment_id` DESC
LIMIT 50

Run Time: 25.316487


Select TypeTableTypePossible KeysKeyKey LenRefRowsExtra
SIMPLExf_xa_ubs_blog_entry_BlogEntry_1rangePRIMARY,category_publish_date,category_last_update,category_rating_weightedcategory_publish_date48514Using index condition; Using temporary; Using filesort
SIMPLExf_xa_ubs_commentrefblog_entry_id_comment_date,blog_entry_id_comment_stateblog_entry_id_comment_state5<redacted>.xf_xa_ubs_blog_entry_BlogEntry_1.blog_entry_id,const8Using index condition
SIMPLExf_user_User_2eq_refPRIMARYPRIMARY4<redacted>.xf_xa_ubs_comment.user_id1
SIMPLExf_xa_ubs_category_Category_3constPRIMARYPRIMARY4const1
SIMPLExf_xa_ubs_blog_Blog_4eq_refPRIMARYPRIMARY4<redacted>.xf_xa_ubs_blog_entry_BlogEntry_1.blog_id1


Code:
XF\Db\Mysqli\Statement->execute() in src/XF/Db/AbstractAdapter.php at line 96
XF\Db\AbstractAdapter->query() in src/XF/Mvc/Entity/Finder.php at line 1445
XF\Mvc\Entity\Finder->fetch() in src/addons/XenAddons/UBS/Widget/LatestComments.php at line 75
XenAddons\UBS\Widget\LatestComments->render() in <redacted>/code_cache/widgets/_31_xa_ubs_latest_comments.php at line 5
XF\SubContainer\Widget->{closure}() in src/XF/Template/Templater.php at line 8177
XF\Template\Templater->renderWidgetClosure() in src/XF/SubContainer/Widget.php at line 176
XF\SubContainer\Widget->getCompiledWidget() in src/XF/Template/Templater.php at line 2144
XF\Template\Templater->widgetPosition() in <redacted>/code_cache/templates/l1/s3/public/xa_ubs_category_view.php at line 452
XF\Template\Templater->{closure}() in src/XF/Template/Templater.php at line 1799
XF\Template\Templater->renderTemplate() in src/XF/Template/Template.php at line 24
XF\Template\Template->render() in src/XF/Mvc/Renderer/Html.php at line 50
XF\Mvc\Renderer\Html->renderView() in src/XF/Mvc/Dispatcher.php at line 471
XF\Mvc\Dispatcher->renderView() in src/XF/Mvc/Dispatcher.php at line 453
XF\Mvc\Dispatcher->renderReply() in src/XF/Mvc/Dispatcher.php at line 412
XF\Mvc\Dispatcher->render() in src/XF/Mvc/Dispatcher.php at line 66
XF\Mvc\Dispatcher->run() in src/XF/App.php at line 2826
XF\App->run() in src/XF.php at line 806
XF::runApp() in index.php at line 23

Category ID #1 has about 220K comments, with this query execution time the widget is (almost) unusable.

Suggested Fix
Add a cutoff setting to limit the amount of possible comments
Store denormalized category_id in xf_xa_ubs_comment (Optional)
 
Back
Top