Added more test to sql-bench
- test-alter now correctly drops all columns - test-alter has a new test that times adding columns in middle of table - test-insert has a new test to check updates that doesn't change data - test-insert: update_with_key_prefix didn't change data. Now fixed
This commit is contained in:
parent
cb16bc95ff
commit
862e602b5a
@ -131,6 +131,7 @@ sub new
|
|||||||
$limits{'alter_add_multi_col'}= 1; #Have ALTER TABLE t add a int,add b int;
|
$limits{'alter_add_multi_col'}= 1; #Have ALTER TABLE t add a int,add b int;
|
||||||
$limits{'alter_table'} = 1; # Have ALTER TABLE
|
$limits{'alter_table'} = 1; # Have ALTER TABLE
|
||||||
$limits{'alter_table_dropcol'}= 1; # Have ALTER TABLE DROP column
|
$limits{'alter_table_dropcol'}= 1; # Have ALTER TABLE DROP column
|
||||||
|
$limits{'alter_table_after'}= 1; # Have ALTER TABLE .. AFTER other_column
|
||||||
$limits{'column_alias'} = 1; # Alias for fields in select statement.
|
$limits{'column_alias'} = 1; # Alias for fields in select statement.
|
||||||
$limits{'func_extra_%'} = 1; # Has % as alias for mod()
|
$limits{'func_extra_%'} = 1; # Has % as alias for mod()
|
||||||
$limits{'func_extra_if'} = 1; # Have function if.
|
$limits{'func_extra_if'} = 1; # Have function if.
|
||||||
|
@ -202,9 +202,10 @@ while ($field_count > $opt_start_field_count)
|
|||||||
$count++;
|
$count++;
|
||||||
$end=max($field_count-$add,$opt_start_field_count);
|
$end=max($field_count-$add,$opt_start_field_count);
|
||||||
$fields="";
|
$fields="";
|
||||||
while(--$field_count >= $end)
|
while ($field_count > $end)
|
||||||
{
|
{
|
||||||
$fields.=",DROP i${field_count}";
|
$fields.=",DROP i${field_count}";
|
||||||
|
$field_count--;
|
||||||
}
|
}
|
||||||
$dbh->do("ALTER TABLE bench " . substr($fields,1) . $server->{'drop_attr'})
|
$dbh->do("ALTER TABLE bench " . substr($fields,1) . $server->{'drop_attr'})
|
||||||
|| die $DBI::errstr;
|
|| die $DBI::errstr;
|
||||||
@ -221,6 +222,39 @@ else
|
|||||||
print " for alter_table_drop ($count): " .
|
print " for alter_table_drop ($count): " .
|
||||||
timestr(timediff($end_time, $loop_time),"all") . "\n\n";
|
timestr(timediff($end_time, $loop_time),"all") . "\n\n";
|
||||||
|
|
||||||
|
####
|
||||||
|
#### Add fields in middle of the table
|
||||||
|
####
|
||||||
|
|
||||||
|
goto skip_dropcol if (!$limits->{'alter_table_after'});
|
||||||
|
|
||||||
|
$count=0;
|
||||||
|
while ($field_count < $opt_field_count)
|
||||||
|
{
|
||||||
|
$count++;
|
||||||
|
$end=min($field_count+$add,$opt_field_count);
|
||||||
|
$fields="";
|
||||||
|
$tmp="ADD ";
|
||||||
|
while ($field_count < $end)
|
||||||
|
{
|
||||||
|
$field_count++;
|
||||||
|
$fields.=",$tmp i${field_count} integer after i1";
|
||||||
|
$tmp="" if (!$multi_add); # Adabas
|
||||||
|
}
|
||||||
|
do_query($dbh,"ALTER TABLE bench " . substr($fields,1));
|
||||||
|
$end_time=new Benchmark;
|
||||||
|
last if ($estimated=predict_query_time($loop_time,$end_time,\$count,$count,
|
||||||
|
$opt_field_count/$add+1));
|
||||||
|
}
|
||||||
|
|
||||||
|
$end_time=new Benchmark;
|
||||||
|
if ($estimated)
|
||||||
|
{ print "Estimated time"; }
|
||||||
|
else
|
||||||
|
{ print "Time"; }
|
||||||
|
print " for alter_table_add_in_middle ($count): " .
|
||||||
|
timestr(timediff($end_time, $loop_time),"all") . "\n\n";
|
||||||
|
|
||||||
skip_dropcol:
|
skip_dropcol:
|
||||||
|
|
||||||
################################ END ###################################
|
################################ END ###################################
|
||||||
|
@ -993,11 +993,22 @@ $end_time=new Benchmark;
|
|||||||
print "Time for update_with_key (" . ($opt_loop_count*3) . "): " .
|
print "Time for update_with_key (" . ($opt_loop_count*3) . "): " .
|
||||||
timestr(timediff($end_time, $loop_time),"all") . "\n";
|
timestr(timediff($end_time, $loop_time),"all") . "\n";
|
||||||
|
|
||||||
|
print "Testing update with key, no changes in data\n";
|
||||||
|
$loop_time=new Benchmark;
|
||||||
|
for ($i=0 ; $i < $opt_loop_count*3 ; $i++)
|
||||||
|
{
|
||||||
|
$sth = $dbh->do("update bench1 set dummy1='updated' where id=$i and id2=$i") or die $DBI::errstr;
|
||||||
|
}
|
||||||
|
|
||||||
|
$end_time=new Benchmark;
|
||||||
|
print "Time for update_with_key_record_unchanged (" . ($opt_loop_count*3) . "): " .
|
||||||
|
timestr(timediff($end_time, $loop_time),"all") . "\n";
|
||||||
|
|
||||||
$loop_time=new Benchmark;
|
$loop_time=new Benchmark;
|
||||||
$count=0;
|
$count=0;
|
||||||
for ($i=1 ; $i < $opt_loop_count*3 ; $i+=3)
|
for ($i=1 ; $i < $opt_loop_count*3 ; $i+=3)
|
||||||
{
|
{
|
||||||
$sth = $dbh->do("update bench1 set dummy1='updated' where id=$i") or die $DBI::errstr;
|
$sth = $dbh->do("update bench1 set dummy1='really updated' where id=$i") or die $DBI::errstr;
|
||||||
$end_time=new Benchmark;
|
$end_time=new Benchmark;
|
||||||
last if ($estimated=predict_query_time($loop_time,$end_time,\$i,($i-1)/3,
|
last if ($estimated=predict_query_time($loop_time,$end_time,\$i,($i-1)/3,
|
||||||
$opt_loop_count));
|
$opt_loop_count));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user