Create a test table
mysql> desc; +-------+-------------+------+-----+---------+----------------+| Field | Type | Null | Key | Default | Extra |+-------+-------------+------+-----+---------+----------------+| ID int(one) | NO | PRI | NULL | auto_increment | | PID int(one) | YES | MUL | NULL | | | name | varchar | NO | MUL | NULL | | +-------+-------------+------+-----+---------+----------------+3inset ( 0.00 sec)
Inserts 10,000 data into it, does not write the stored procedure, only uses the shell to insert the
#!/bin/bash# generates random numbers for a specified rangefunctionrand () {min=$1Max=$(($2-$1+1) Num=$ (($RANDOM +100000000)) Echo$ (($num% $max +$min))} forJinch{1.. -} DoSQL='insert INTO (pid,name) values'; forIinch{1.. -} DoRandnum=$ (Rand1 10000) Randstr=$(Date+%s%n | md5sum |Head-CTen) SQL= $sql"(' $randnum ', ' $randstr ')," DoneSQL=${sql%,*} /home/work/.jumbo/bin/mysql-u ROOT-P123-E"Use test; $sql" Done
mysql--test whether the prefix index can be used for order by or GROUP by