MySQL怎麼在select中用索引

來源:互聯網
上載者:User
MySQL如何在select中用索引
給列(名為:column_a,素在表為:table_a)定義一個索引(名為:index_a);

我搜尋列column_a時用一般方法

select column_a from table_a where 條件運算式;

那用上索引index_a應該怎樣用呢?

------解決方案--------------------
沒有理解索引,建立索引的目的為了大資料量時的查詢效能,

使用時,一般是where 後面帶有 column_a 的查詢條件可以了,就會比不建立索引進行搜尋時快許多,在一定資料量時可以看出來
------解決方案--------------------
explain一下你的sql,在key欄位可以看到是否使用了索引
------解決方案--------------------
看你的where條件是什麼了 ,可以
explain select column_a from table_a where 條件運算式;
看是否使用了索引。
  • 聯繫我們

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