If you want to test the performance of the SQL statements or just want to test the Database performance, you will need to generate lots of records in a table. The following defines a MySQL procedure named autoGenerate and what it does is generate 100K records of test data with ID and time.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | DROP PROCEDURE autoGenerate ; DELIMITER $$ CREATE PROCEDURE autoGenerate () BEGIN DECLARE i INT DEFAULT 0 ; SET autocommit = 0; -- Start WHILE (i < 100000) DO -- Terminate REPLACE INTO TEST (id, ctime) VALUE (i, NOW()) ; SET i = i + 1 ; IF i%1000=0 THEN COMMIT; END IF; END WHILE ; SET autocommit =1; COMMIT; END $$ DELIMITER ; CALL autoGenerate(); |
DROP PROCEDURE autoGenerate ; DELIMITER $$ CREATE PROCEDURE autoGenerate () BEGIN DECLARE i INT DEFAULT 0 ; SET autocommit = 0; -- Start WHILE (i < 100000) DO -- Terminate REPLACE INTO TEST (id, ctime) VALUE (i, NOW()) ; SET i = i + 1 ; IF i%1000=0 THEN COMMIT; END IF; END WHILE ; SET autocommit =1; COMMIT; END $$ DELIMITER ; CALL autoGenerate();
You could easily modify the number of rows, or the columns to suit your needs. Every 1000 rows are inserted, the MySQL will commit the transaction, so make sure the table is typed of inno instead of MyISAM.
--EOF (The Ultimate Computing & Technology Blog) --
GD Star Rating
loading...
233 wordsloading...
Last Post: How to Compute Minkowski, Euclidean and CityBlock Distance in C++?
Next Post: How to Define Inheritable Record/Structure in Delphi (Object Pascal)?