SHOW VARIABLES LIKE "%slow%";
SHOW FULL PROCESSLIST;
SET profiling=1;
SELECT * FROM `score_cal_unsuccessed`;
SHOW PROFILES;
SHOW PROFILE FOR QUERY 28;
SHOW STATUS;
SHOW GLOBAL STATUS; //mysqladmin ext -i1 每秒执行一次
FLUSH STATUS;
EXPLAIN SELECT * FROM `score_cal_unsuccessed`;
SHOW STATUS WHERE VARIABLE_NAME LIKE 'Handler%' OR VARIABLE_NAME LIKE 'Created%';
CREATE TABLE char_test(char_col VARCHAR(10));/*char 去掉 string3后面的空格 但是varchar会保留*/
INSERT INTO char_test(char_col) VALUES('string1'),(' string2'),('string3 ');
SELECT CONCAT("'",char_col,"'") FROM char_test;
DROP TABLE char_test;
SHOW VARIABLES LIKE '%max_sort_length%'/*Maximum sort word length*/
SELECT SQL_NO_CACHE COUNT(*) FROM a JOIN b USING (column 1, column 2, column 3)
SHOW CREATE TABLE `activity_group0` /* sql creation statement for this table */
ON DUPLICATE KEY UPDATE
syntax
If ON is specified at the end of the INSERT statement DUPLICATE KEY UPDATE, and after inserting a row will cause a duplicate value in a UNIQUE index or PRIMARY KEY, perform UPDATE on the row with duplicate value; if it does not cause the problem of duplicate unique value columns, insert a new row.
For example, if column a is the primary key or has a UNIQUE index, and contains the value 1, the following two statements have the same effect
:
INSERT INTO TABLE (a,c) VALUES (1,3) ON DUPLICATE KEY UPDATE c=c+1;
UPDATE TABLE SET c=c+1 WHERE a=1;
IF syntax
UPDATE daily_hit_counter AS c
INNER JOIN (
SELECT day,SUM(cnt) AS cnt,MIN(slot) AS mslot
FROM daily_hit_counter
GROUP BY day
) AS x USING(DAY)
SET c.cnt=IF(c.slot=x.mslot,x.cnt,0)
SET c.slot=IF(c.slot=x.mslot,0,c.slot)
<=>operator
'a' IS NULL ==> 'a' <=> NULL
'a' IS NOT NULL ==> NOT('a' <=> NULL)
EXPLAIN EXTENDED SELECT * FROM `score_cal_unsuccessed`
SHOW WARNINGS; You can see the refactored query statement.
"STRAIGHT_JOIN" forced connection (JOIN) order Compile and install the
performance analysis tool
percona-toolkit
:
tar xzvf percona-toolkit-2.1.1.tar.gz
cd percona-toolkit-2.1.1
perl Makefile.PL
make
make install
use: https://www.percona.com/doc/percona-toolkit/2.2/pt-query-digest.html
pt-query-digest slow.log
pt-query-digest --processlist h=host1
high performance mysql
Guess you like
Origin http://10.200.1.11:23101/article/api/json?id=327086340&siteId=291194637
Recommended
Ranking