query_init: # # Read table sizes from TABLE_SIZES env. variable. # { @max= @init= split(/ +/,"0 $ENV{TABLE_SIZES}"); $table_count= @init - 1; undef } # # Subroutines for inserting/deleting rows from tables # { sub t_insert() { my $t= shift; $key=++$max[$t]; print "INSERT INTO $tbl VALUES ($key,1);\n"; } } { sub t_delete() { my $t= shift; $key=$max[$t]--; print "DELETE FROM $tbl WHERE k=$key\n"; } } # SET @AUTOCOMMIT=1; USE db1 ; query: { $t= $prng->int(1,$table_count); $tbl="t$t"; $max=$max[$t]; $ini= $init[$t]; undef } dml ; # # Note: original proportions of select/update/insert/delete were as # 60/38/1/1 which we reproduce here # dml: select | select | select | select | select | select | select | select | select | select | select | select | select | select | select | select | select | select | select | select | select | select | select | select | select | select | select | select | select | select | select | select | select | select | select | select | select | select | select | select | select | select | select | select | select | select | select | select | select | select | select | select | select | select | select | select | select | select | select | select | update | update | update | update | update | update | update | update | update | update | update | update | update | update | update | update | update | update | update | update | update | update | update | update | update | update | update | update | update | update | update | update | update | update | update | update | update | update | | insert | delete ; select: SELECT * FROM $tbl WHERE k= { $key= $prng->int(1,$max) } ; update: UPDATE $tbl SET i=i+1 WHERE k= { $key= $prng->int(1,$max) } ; insert: { $max > 1.5*$ini ? &t_delete($t) : &t_insert($t) ; undef } ; delete: { $max < 0.5*$ini ? &t_insert($t) : &t_delete($t) ; undef } ;