Thursday, March 15, 2007

Insert 1 million data to mysql table within 4 miniutes

I had inserted 1 million data to mysql table within 4 minutes using for loop which is wirreten in PHP. Code is mention below.

mysql_connect("localhost", "root", "");
mysql_select_db("sahana");
mysql_query("INSERT INTO `field_options` VALUES ('opt_skill_type', 'AUT4', 'AUTOMOTIVE Skilled - Tire Repair')");

for ($counter = 1; $counter <= 500000; $counter += 1) {

echo $counter;
mysql_query("INSERT INTO `field_options` VALUES ('opt_skill_type', 'AUT4', 'AUTOMOTIVE Skilled - Tire Repair')");
}
?>

I had execute this file two times then it is 1 million of data this type of methods you can use for testing purpose.

See how exciting is these kind of crazy things.