小貝_mysql分區執行個體

來源:互聯網
上載者:User

標籤:mysql   最佳化   

mysql分區實驗簡要:一、按照分區類型建立分區二、管理分區三、分區與未分區表例子

 

一、建立分區以hash分區為例

       (1)、非線性hash分區

1、測試表t_hash結構

create table t_hash

(id int unsigned,

name char(1)

)engine=myisam charset=utf8

partition by hash(id)

partitions 5;

   

       2、t_hash表物理檔案結構

       3、往t_hash表插入資料

      

       4、查看錶t_hash物理結構


       總結: hash分區是平均分布。因此每個分區的資料檔案大小是相等的。

 

二、管理分區

       1、針對hash分區

      

       2、把分區數5調整為2

      

      

       3、把分區數2調整為1

      

總結:一旦進行hash分區,那麼至少存在一個分區。

 

三、分區與未分區表例子

1、測試表

未分區表:

create table t2

(id int unsigned,

name char(1)

)engine=myisam charset=utf8;

 

分區表:

create table t1

(id int unsigned,

name char(1)

)engine=myisam charset=utf8

partition by hash(id)

partitions 4;

 

 

 

 

 


2、插入相同條數的資料


3、尋找name為a的資料


(備忘: 在沒有添加索引的情況下,分區的所花費的時間比未分區的小)


The quieter you become,the more you are able to hear!

著作權聲明:本文為博主原創文章,未經博主允許不得轉載。

小貝_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.