Mysql int和binary的插入速度
我读了帖子:。看来 列的数量将显著降低插入速度。所以我创建了两个表: 第一个包含100个tinyint列和100个smallint列,第二个包含 一个binary100列和一个binary200列。所以这两个表具有相同的行长度 更具体地说:Mysql int和binary的插入速度,mysql,Mysql,我读了帖子:。看来 列的数量将显著降低插入速度。所以我创建了两个表: 第一个包含100个tinyint列和100个smallint列,第二个包含 一个binary100列和一个binary200列。所以这两个表具有相同的行长度 更具体地说: CREATE TABLE 'users'( 'c0' tinyint(4) not null default '0', 'd0' smallint(6) not null default '0', ..... 'c99' ti
CREATE TABLE 'users'(
'c0' tinyint(4) not null default '0',
'd0' smallint(6) not null default '0',
.....
'c99' tinyint(4) not null default '0',
'd99' smallint(6) not null default '0'
) ENGINE = InnoDB default CHARSET = utf8
CREATE TABLE 'users2'(
'c0' binary(100) not null default '\0 *100',
'd0' binary(200) not null default '\0 * 200'
) ENGINE = InnoDB default CHARSET = utf8
然后,我从mysql工作台运行了以下两个过程
create procedure insert1()
begin
declare v_max int default 1000;
declare v_counter int default 0;
while v_counter < v_max do
insert into user (c0, d0, c1, d1....c99, d99) values (0,0,0.....0);
set v_counter = v_counter + 1;
end while;
end
create procedure insert2()
begin
declare v_max int default 1000;
declare v_counter int default 0;
while v_counter < v_max do
insert into users2 (c0, d0) values (0x0000...00, 0x000....00);
set v_counter = v_counter + 1;
end while;
end
结果是:
呼叫插入器1:0.999秒
呼叫插入2:3.479秒
由于这两个表具有相同的行长度,并且第一个表的列数超过200列,因此我希望第一个表的插入速度应该比第二个表慢。
有人能解释一下为什么会这样吗?提前谢谢你 必须将binary100更改为binary4,将binary200更改为binary6。 我听说binaryn表示n=1字节,而不是二进制数字