MySQL List分區(三),mysqllist分區

來源:互聯網
上載者:User

MySQL List分區(三),mysqllist分區

詳細介紹請看   MySQL分區一

例子:該例子為本人個人學習總結分享






mysql 怎給已有表分區

我也在找方法 mysql自從5.1開始就可以表分區了。
 
mysql 分區的欄位 與 where 的條件有什樣的關係

1、為什麼沒加索引時,兩個表執行的記錄數一樣,難道分區的欄位c3一定要包含在where條件裡分區才生效嗎?

對的.
因為 你分區, 還是不分區。 where c2='1'
最後結果都是 “全表掃描”

對於 分區的表, 意味著每一個分區的每一行, 就要掃描到, 才知道是否滿足 where c2='1' 的條件。
對於 未分區的表, 就是這個表的每一行,都要掃描到了。

2、加了索引後,未分區的表比分區的表執行的記錄數還要少,這是為什嗎?

你這個分區表上面的索引, 我估計是局部索引。
也就是 當 where c3=... and c2= ... 的時候, 能夠達到最好的效果。
當只有 where c2 = ... 的時候。

先要依次判斷每一個分區, 然後在那個分區裡面去 使用索引。
所以資源消耗, 要比那個 不分區的表, 要高一些。
 

相關文章

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.