When writing data to disk, for small transactions the cost of writing the commit out do disk dominates the execution time of the script. In order to show that, I wrote a little bit of Python.
The script creates a test table in a database and writes 10.000 rows of test data into it, in commit sizes of 1, 2, 4, …, 1024 rows.
$ ./mysql.py --help
Usage: mysql.py [OPTIONS] COMMAND [ARGS]...
Test commit sizes.
Options:
--help Show this message and exit.
Commands:
create Create the demo table empty.
drop Drop the demo table
fill Write test records into the demo table.
truncate Truncate the demo table.
There is a small driver script to run the test. The driver creates the table, truncates it and will then run the fill command of the script over and over again, with growing commit-sizes. All powers of 2 from 0 to 10 are being tried with 10.000 rows of test data.
The test system has a …
[Read more]