bitscn.com对比一下,首先是用 mysql 的存储过程弄的:
mysql>delimiter $
mysql>set autocommit = 0$$
mysql> create procedure test()
begin
declare i decimal (10) default 0 ;
dd:loop
insert into `million` (`categ_id`, `categ_fid`, `sortpath`, `address`, `p_identifier`, `pro_specification`, `name`, `add_date`, `picture_url`, `thumb_url`, `is_display_front`, `create_html_time`, `hit`, `buy_sum`, `athor`, `templete _style`, `is_hot`, `is_new`, `is_best`) values
(268, 2, '0,262,268,', 0, '2342', '423423', '123123', '2012-01-09 09:55:43', 'upload/product/20111205153432_53211.jpg', 'upload/product/thumb_20111205153432_53211.jpg', 1, 0, 0, 0, 'admin', '0', 0, 0, 0);
commit;
set i = i+1;
if i= 1000000 then leave dd;
end if;
end loop dd ;
end;$
mysql>delimiter ;
mysql> call test;
结果
mysql> call test; query ok, 0 rows affected (58 min 30.83 sec)
非常耗时。
于是我又找了一个方法
先用php代码生成数据,再导入:
= (select floor(rand() * (select max(itemid) from `downitems`))) order by itemid limit 1000;
然后可以修改1000的数字了。改为5000或者1万。很快可以达到100万的数据量了。bitscn.com