Performance of MEMORY Tables
Example of benchmarking the MEMORY table using perl to generate the data and SQL for the benchmark
Between MariaDB 5.5.21 and 5.5.22 some work was done on how the hash index for a MEMORY table is created. This results in better performance when inserting rows into a memory table.
The following benchmark compares MariaDB 5.5.21 and 5.5.25. Compiled with identical settings on the same machine. The operation was loading 50 million rows into a MEMORY table with LOAD DATA INFILE.
Two different tables were tested: one with an indexed INT column and one with an indexed CHAR(20) column. The data files were pre-generated and located on a SSD. In order to make the effect visible, the cpu speed was set to minimum (core I5 @ 800Mhz)
Result:
INT
5.5.21
411022
100%
5.5.25
510016
124%
CHAR(20)
5.5.21
259399
100%
5.5.25
411535
159%
This is how the benchmark was run:
MariaDB [test]> tee 5.5.21.txt
MariaDB [test]> set @instance="5.5.21";
MariaDB [test]> source bench.sqlThe script used to generate the data files:
#!/usr/bin/perl -w
$ROWS=50*1024*1024;
open F, ">/tmp/hash1.txt" or die;
for ($i=0; $i<$ROWS; $i++) {
printf F "%d\n", int(rand($ROWS));
}
close F or die;
open F, ">/tmp/hash2.txt" or die;
for ($i=0; $i<$ROWS; $i++) {
$s="";
for (1..20) { $s .= chr(ord('a')+int(rand(26))); }
print F $s, "\n";
}
close F or die;The benchmark SQL script bench.sql:
This page is licensed: CC BY-SA / Gnu FDL
Last updated
Was this helpful?

