msyql統計效能

來源:互聯網
上載者:User

索引的設計:

1. 索引的設計應根據實際的統計需求而定,主要體現在order by, group by的需求上

2. 過多的需求不應導致過多的索引: key base1(...),key base2(...),... 過多的索引會導致insert,update相當費時

3. 索引的欄位應該為各類order by, group by的欄位的公用首碼,而不是過多的索引。如 group by a,b,c,d;group by a,b,c,e 則索引應該為key base(a,b,c). 而不是建立兩個索引 key base1(a,b,c,d),key base2(a,b,c,e)

4. 用desc/explain可能發現有:Using where; Using temporary; Using filesort . 此時可能考慮要最佳化。當然資料兩過大,group by的欄位不應設為索引也無法避免 Using temporary。但合理地設計索引同樣會提高 Using temporary的效率

5. 索引的設計應該精簡合理,不混亂錯綜

6. mysql的核心在於索引

 

資料的插入:

1. mysqlimport 實際調用了load data...  其效率比insert高。所以資料入庫應該使用mysqlimport 而不是逐條insert

2. 如有可能,使用awk指令碼將檔案分塊確實方便

 

其他:

1. 每天應該總結,思考,學習

2. 別拘於工作,應該拓展

 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.