Use of Mysqldumpslow:
For example, we want to query the first 5 log messages by time, in the following format:
Mysqldumpslow-s t-t 5/var/log/mysql/slowquery_20180303.log
Parameter description:
-S: Sort by lock time L, number of records returned R, query time t, record number of times C, reverse can be added R
-T: How many records before querying
-G: Supports regular expressions, and ignores case
By the way explain
Explain is used to analyze the MySQL query structure with the main focus on four parameter values:
Type, key, rows, extras
Access type Type:al worst, ref,eq_ref centered, null best
All->index->range->ref->eq_ref->const or System->null
There is no use index Key:key is empty no index is used
Find the number of rows to read for the desired record: the smaller the rows,rows value, the better.
Extras: In what way a required record is found, a using Filesort or using temporary indicates inefficiency, only index is indexed, where used uses the where filter condition, impossible where No use to index
Mysqldumpslow Analysis Slow query log and explain analysis MySQL queries structure