數(shù)據(jù)庫優(yōu)化從4個(gè)方向去優(yōu)化
1、sql和索引,寫出健壯的sql,索引不是越多越好
2、數(shù)據(jù)表結(jié)構(gòu)(存儲(chǔ)引擎,字段大小,字段類型,索引,第三規(guī)范)
3、系統(tǒng)配置(打開文件系統(tǒng)次數(shù),文件安全性)
4、硬件(更合適的cup,更大的內(nèi)存,更快的io,cup并不是越大越好)
show variables like 'slow_query_log' 查詢慢查詢?nèi)罩?br> set globel slow_query_log_file = '/home/mysql/sql_log/mysql-slow.log' 設(shè)置慢查詢?nèi)罩镜穆窂?br> set global log_queries_not_using_indexes = on; 設(shè)置慢查詢?nèi)罩臼欠裼涗浳刺砑铀饕淖侄?br> set global long_query_time = 1 設(shè)置記錄慢查詢?nèi)罩緯r(shí)間
mysqldumpslow -t 3 url | more