在Mysql中遇到關於區間範圍內的索引最佳化

來源:互聯網
上載者:User

標籤:sql   dex   資料   範圍   通過   注意   type   比較   策略   

上次調優Mysql 的時候,發現有些語句並沒有用到索引,這引起了我的注意,發現在大資料量的情況下,由於資料的不同,會導致索引策略的更改!

通過explain命令進行查看發現結果資料過大的話type會變為index。

索引應該儘可能減少區間範圍,減少結果。

PS:在昨天的sql‘研究中,還發現如果是select * from xxx where lat>xx and lat <xx and lng>xxx and lng <xxx更正為 select * from xxx where lat between xx and xx and lng between xx and xx 比較好。 並分別對 lat 和 lng 設定索引

 

在Mysql中遇到關於區間範圍內的索引最佳化

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.