Slow request takes .0007s? Why is this happening in my slow motion?

SELECT vt.vtid, vt.tag, vt.typeid, vt.id, vt.count, tt.type, u.username, vt.date_added, tc.context, tc.contextid FROM ( vt, tt, u ) LEFT JOIN tc ON ( vt.vtid = tc.vtid AND tc.userid = vt.userid ) WHERE vt.typeid = tt.typeid AND vt.verified =0 AND vt.userid = u.userid ORDER BY vt.date_added DESC LIMIT 1 

takes .0007s to complete

 id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE vt ref typeid,userid,verified verified 1 const 9 Using where; Using filesort 1 SIMPLE tt eq_ref PRIMARY PRIMARY 4 vt.typeid 1 1 SIMPLE tc ref vtid vtid 4 vt.vtid 3 1 SIMPLE u eq_ref PRIMARY PRIMARY 4 vt.userid 1 Using where 

How can I change this to not appear in the slow query log?

+4
source share
2 answers

Just to guess. You may have set the log-queries-not-using-indexes flag. According to the documentation, this can lead to queries being logged in a slow log, even if indexes are used.

+5
source

I am sure a1ex07 is correct.

However, if you want to speed up this request a bit, you can change your index to tc by specifying the vtid index as an index to (vtid, userid). Such complex keys are much faster if you join both keys, and almost exactly as fast if you just join the first field.

0
source

Source: https://habr.com/ru/post/1338182/


All Articles