想测试下表分区功能跟自主的分布式的性能差异,进行了简单的测试,前后花费了半个小时,可能测试数据不太准确。
【测试环境】
操作系统:Windows XP SP2
MySQL: 5.1.19-beta-community-nt-debug
【测试过程】
查看MySQL版本:
mysql> select version();
+--------------------------------+
| version() |
+--------------------------------+
| 5.1.19-beta-community-nt-debug |
+--------------------------------+
1 row in set (0.00 sec)
建立分区表:
mysql> create table p1 (
-> id int(10) not null auto_increment,
-> username varchar(32) default '',
-> email varchar(64) default '',
-> created datetime default '0000-00-00 00:00:00',
-> primary key (id)
-> ) engine=myisam
-> partition by range(id)(
-> partition p1 values less than (10000),
-> partition p2 values less than (20000),
-> partition p3 values less than (30000),
-> partition p4 values less than (40000),
-> partition p5 values less than (50000),
-> partition p6 values less than (60000),
-> partition p7 values less than (70000),
-> partition p8 values less than (80000),
-> partition p9 values less than (90000),
-> partition p10 values less than maxvalue
-> );
Query OK, 0 rows affected (0.08 sec)
建立不分区(普通表):
mysql> create table p2 (
-> id int(10) not null auto_increment,
-> username varchar(32) default '',
-> email varchar(64) default '',
-> created datetime default '0000-00-00 00:00:00',
-> primary key (id)
-> ) engine=myisam;
Query OK, 0 rows affected (0.00 sec)
插入数据的存储过程:
mysql> delimiter //
mysql> create procedure load_tab()
-> begin
-> declare v int default 0;
-> while v < 100000
-> do
-> insert into p1 (username,email,created) values ('jack', 'jack@example.com', now());
-> set v = v + 1;
-> end while;
-> end
-> //
Query OK, 0 rows affected (0.00 sec)
给两个表分别插入