All database structures are as follows, some IDs are int, see comments
100W Data:
ID is an indexed field, 4 bytes of int, and the database engine is MyISAM
Echo"<br>". Xdebug_time_index (). " <br> "; 0.011001110076904 for($i= 0;$i< 10000;$i++) { $random=Mt_rand(1,999999); $id=$random; $sql= "SELECT * from test100m where id=".$id.""; $result=mysql_query($sql,$con);}Echo"<br>". Xdebug_time_index (). " <br> "; 1.0551059246063
10,000 queries, 1s or so, each select 0.1ms
100W Data:
ID is an indexed field, 4 bytes of int, and the database engine is InnoDB
Echo"<br>". Xdebug_time_index (). " <br> "; 0.011001110076904 for($i= 0;$i< 10000;$i++) { $random=Mt_rand(1,999999); $id=$random; $sql= "SELECT * from Test100m_innodb where id=".$id.""; $result=mysql_query($sql,$con);}Echo"<br>". Xdebug_time_index (). " <br> "; 1.1981191635132
10,000 queries, 1s or so, each select 0.1ms
200W Data:
ID is an indexed field, 4 bytes of int, and the database engine is InnoDB
Echo"<br>". Xdebug_time_index (). " <br> "; 0.00099992752075195 for($i= 0;$i< 1000;$i++) { $random=Mt_rand(1,1999999); $id=$random; $sql= "SELECT * from test200m where id=".$id.""; $result=mysql_query($sql,$con); }Echo"<br>". Xdebug_time_index (). " <br> "; 4.5234520435333
1000 queries, 4.5s or so, each select 4.5ms
500W Data:
ID is an indexed field, 4 bytes of int, and the database engine is InnoDB
Echo"<br>". Xdebug_time_index (). " <br> "; 0.0010001659393311 for($i= 0;$i< 1000;$i++) { $random=Mt_rand(1,4999999); $id=$random; $sql= "SELECT * from test500m where id=".$id.""; $result=mysql_query($sql,$con); }Echo"<br>". Xdebug_time_index (). " <br> "; 5.0744871616364
1000 queries, 5s or so, each select 5ms
1000W Data:
ID is an indexed field, 4 bytes of int, and the database engine is MyISAM
Echo"<br>". Xdebug_time_index (). " <br> "; 0.0010008811950684 for($i= 0;$i< 100;$i++) { $random=Mt_rand(1,9999999); $id=$random; $sql= "SELECT * from test1000m where id=".$id.""; $result=mysql_query($sql,$con); }Echo"<br>". Xdebug_time_index (). " <br> "; 1.5391540527344
100 queries, 1.5s or so, each select 15ms
1000W Data:
ID is an indexed field, 8 bytes of bigint, and the database engine is MyISAM
Echo"<br>". Xdebug_time_index (). " <br> "; 0.00099992752075195 for($i= 0;$i< 100;$i++) { $random=Mt_rand(1,9999999); $id=$random.‘ 0 '.$random.‘ 0 '; $sql= "SELECT * from Test1000m_bigint where id=".$id.""; $result=mysql_query($sql,$con);}Echo"<br>". Xdebug_time_index (). " <br> "; 1.2141208648682
100 times, 1.2s, average per select 12ms
1000W Data:
ID is an indexed field, 8 bytes of bigint, and the database engine is MyISAM
Code as above
100 times, 1.2s, average per select 12ms
Conclusion:
Data volume engine average Time index field
100W MyISAM 0.1ms
100W InnoDB 0.1ms
200W InnoDB 4.5ms
500W InnoDB 5ms
1000W MyISAM 15ms (paralysis is incredibly slower than bigint)
1000W InnoDB 12ms (bigint)
1000W MyISAM 12ms (bigint)
MySQL Performance test PHP version