mysql> CREATE TABLE `test_t` (
-> `id` int(11) NOT NULL auto_increment,
-> `num` int(11) NOT NULL default '0',
-> `d_num` varchar(30) NOT NULL default '0',
-> ) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
Query OK, 0 rows affected (0.05 sec)
mysql> CREATE TABLE `test_test` (
-> `id` int(11) NOT NULL auto_increment,
-> `num` int(11) NOT NULL default '0',
-> ) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
Query OK, 0 rows affected (0.05 sec)
mysql> create procedure i_test(pa int(11),tab varchar(30))
-> declare max_num int(11) default 100000;
-> declare i int default 0;
-> declare double_num char;
-> if tab != 'test_test' then
->selectcount(id) into max_num from test_t;
-> if max_num < 100000 then
-> select cast(rand()*100 as unsigned) into rand_num;
-> select concat(rand_num,rand_num) into double_num;
-> insert into test_t(num,d_num)values(rand_num,double_num);
-> select count(id) into max_num from test_test;
-> if max_num < 100000 then
-> select cast(rand()*100 as unsigned) into rand_num;
-> insert into test_test(num)values(rand_num);
Query OK, 0 rows affected (0.00 sec)
mysql> show variables like "%pro%"; //查看一下,记录执行的profiling是不是开启动了,默认是不开启的
+---------------------------+-------+
| Variable_name | Value |
+---------------------------+-------+
| profiling_history_size | 15 |
| protocol_version | 10 |
| slave_compressed_protocol | OFF |
+---------------------------+-------+
mysql> set profiling=1; //开启后,是为了对比加了索引后的执行时间
Query OK, 0 rows affected (0.00 sec)