I've been going through our slow queries today and this one accounts for 20% of them:
---
What is it and can it be improved?
There's another slow one too:
Code:
______________________________________________________________________ 001 ___
Count : 163 (20.10%)
Time : 475 s total, 2.91411 s avg, 2 s to 7 s max (17.18%)
95% of Time : 423 s total, 2.746753 s avg, 2 s to 5 s max
Lock Time (s) : 8 s total, 49.08 ms avg, 0 to 2 s max (10.39%)
95% of Lock : 0 total, 0 avg, 0 to 0 max
Rows sent : 20 avg, 20 to 20 max (16.48%)
Rows examined : 152.18k avg, 94.65k to 214.96k max (58.21%)
Database : xxxxxxxxxxxxxx
Users :
admin@localhost : 100.00% (163) of query, 62.76% (509) of all users
Query abstract:
SELECT rewards.*, user.* , avatar.avatarpath, NOT isnull(customavatar.userid) AS hascustomavatar, customavatar.dateline AS avatardateline, customavatar.width AS avwidth, customavatar.height AS avheight, customavatar.height_thumb AS avheight_thumb, customavatar.width_thumb AS avwidth_thumb, customavatar.filedata_thumb FROM vb_dbtech_vbactivity_rewards AS rewards LEFT JOIN vb_user AS user ON (user.userid = rewards.userid) LEFT JOIN vb_avatar AS avatar ON (avatar.avatarid = user.avatarid) LEFT JOIN vb_customavatar AS customavatar ON (customavatar.userid = user.userid) WHERE user.dbtech_vbactivity_excluded_tmp = 'S' AND feature = 'S' ORDER BY dateline DESC LIMIT N, N;
Query sample:
SELECT
rewards.*,
user.*
, avatar.avatarpath, NOT ISNULL(customavatar.userid) AS hascustomavatar, customavatar.dateline AS avatardateline, customavatar.width AS avwidth, customavatar.height AS avheight, customavatar.height_thumb AS avheight_thumb, customavatar.width_thumb AS avwidth_thumb, customavatar.filedata_thumb
FROM vb_dbtech_vbactivity_rewards AS rewards
LEFT JOIN vb_user AS user ON (user.userid = rewards.userid)
LEFT JOIN vb_avatar AS avatar ON (avatar.avatarid = user.avatarid)
LEFT JOIN vb_customavatar AS customavatar ON (customavatar.userid = user.userid)
WHERE
user.dbtech_vbactivity_excluded_tmp = '0'
AND feature = 'achievement'
ORDER BY dateline DESC
LIMIT 20340, 20;
What is it and can it be improved?
There's another slow one too:
Code:
______________________________________________________________________ 003 ___
Count : 37 (4.56%)
Time : 153 s total, 4.135135 s avg, 2 s to 9 s max (5.53%)
95% of Time : 135 s total, 3.857143 s avg, 2 s to 7 s max
Lock Time (s) : 8 s total, 216.216 ms avg, 0 to 4 s max (10.39%)
95% of Lock : 1 s total, 28.571 ms avg, 0 to 1 s max
Rows sent : 0 avg, 0 to 0 max (0.00%)
Rows examined : 0 avg, 0 to 0 max (0.00%)
Database : xxxxxxxxxxxxx
Users :
admin@localhost : 100.00% (37) of query, 62.76% (509) of all users
Query abstract:
UPDATE vb_user SET dbtech_vbactivity_excluded_tmp = IF(dbtech_vbactivity_excluded = 'S' OR find_in_set(N, membergroupids) OR find_in_set(N, membergroupids) OR find_in_set(N, membergroupids) OR usergroupid IN(N3), 'S', 'S');
Query sample:
UPDATE vb_user
SET dbtech_vbactivity_excluded_tmp = IF(dbtech_vbactivity_excluded = '1'
OR FIND_IN_SET(17, membergroupids) OR FIND_IN_SET(8, membergroupids) OR FIND_IN_SET(18, membergroupids)
OR usergroupid IN(17,8,18), '1', '0');
Last edited: