高性能mysql

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%'/*最大排序字长*/

SELECT SQL_NO_CACHE COUNT(*) FROM a JOIN b USING(列1,列2,列3)
性能分析工具 percona-toolkit的编译安装方式:
tar xzvf percona-toolkit-2.1.1.tar.gz
cd percona-toolkit-2.1.1
perl Makefile.PL
make
make install


使用:https://www.percona.com/doc/percona-toolkit/2.2/pt-query-digest.html
pt-query-digest slow.log
pt-query-digest --processlist h=host1

你可能感兴趣的:(mysql)