diff options
author | monty@hundin.mysql.fi <> | 2001-11-22 17:55:18 +0200 |
---|---|---|
committer | monty@hundin.mysql.fi <> | 2001-11-22 17:55:18 +0200 |
commit | a66ddaf8ba4b7e5478c376ce65b57d6fdf25607b (patch) | |
tree | 5c88c46555c8f2f0d49c779e6347d2d6139a84e0 /sql-bench | |
parent | 9265a4df45ea24b029ce024df7c9f34b7248a0d0 (diff) | |
download | mariadb-git-a66ddaf8ba4b7e5478c376ce65b57d6fdf25607b.tar.gz |
Fixed fulltext after merge from 3.23.45
First (incomplete) version of transaction and as3ap tests.
Diffstat (limited to 'sql-bench')
-rw-r--r-- | sql-bench/Makefile.am | 4 | ||||
-rw-r--r-- | sql-bench/as3ap.sh | 636 | ||||
-rw-r--r-- | sql-bench/run-all-tests.sh | 4 | ||||
-rw-r--r-- | sql-bench/server-cfg.sh | 30 | ||||
-rw-r--r-- | sql-bench/test-ATIS.sh | 3 | ||||
-rw-r--r-- | sql-bench/test-transactions.sh | 268 |
6 files changed, 941 insertions, 4 deletions
diff --git a/sql-bench/Makefile.am b/sql-bench/Makefile.am index e9c3e07beef..4bfa9868428 100644 --- a/sql-bench/Makefile.am +++ b/sql-bench/Makefile.am @@ -21,13 +21,15 @@ benchdir_root= $(prefix) benchdir = $(benchdir_root)/sql-bench bench_SCRIPTS = test-ATIS test-connect test-create test-insert \ test-big-tables test-select test-wisconsin \ - test-alter-table graph-compare-results \ + test-alter-table test-transactions \ + graph-compare-results \ bench-init.pl compare-results run-all-tests \ server-cfg crash-me copy-db bench-count-distinct CLEANFILES = $(bench_SCRIPTS) EXTRA_SCRIPTS = test-ATIS.sh test-connect.sh test-create.sh \ test-insert.sh test-big-tables.sh test-select.sh \ test-alter-table.sh test-wisconsin.sh \ + test-transactions.sh \ bench-init.pl.sh compare-results.sh server-cfg.sh \ run-all-tests.sh crash-me.sh copy-db.sh \ bench-count-distinct.sh graph-compare-results.sh diff --git a/sql-bench/as3ap.sh b/sql-bench/as3ap.sh new file mode 100644 index 00000000000..ed796249ebb --- /dev/null +++ b/sql-bench/as3ap.sh @@ -0,0 +1,636 @@ +#!@PERL@ +# Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Library General Public +# License as published by the Free Software Foundation; either +# version 2 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Library General Public License for more details. +# +# You should have received a copy of the GNU Library General Public +# License along with this library; if not, write to the Free +# Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, +# MA 02111-1307, USA +# +# AS3AP single-user benchmark. +# + +##################### Standard benchmark inits ############################## + +use DBI; +use Benchmark; + +chomp($pwd = `pwd`); $pwd = "." if ($pwd eq ''); +require "$pwd/bench-init.pl" || die "Can't read Configuration file: $!\n"; + +$opt_loop_count=1; + +#Create tables + +$dbh = $server->connect(); + +#Create Table +$sth = $dbh->do("drop table uniques"); +$sth = $dbh->do("drop table updates"); +$sth = $dbh->do("drop table hundred"); +$sth = $dbh->do("drop table tenpct"); +$sth = $dbh->do("drop table tiny"); + +#Temporary table +$sth = $dbh->do("drop table saveupdates"); + +@fields=("col_key int not null", + "col_int int not null", + "col_signed int not null", + "col_float float not null", + "col_double float not null", + "col_decim numeric(18,2) not null", + "col_date char(20) not null", + "col_code char(10) not null", + "col_name char(20) not null", + "col_address varchar(80) not null"); + +do_many($dbh,$server->create("uniques",\@fields,[])); +do_many($dbh,$server->create("updates",\@fields,[])); +do_many($dbh,$server->create("hundred",\@fields,[])); +do_many($dbh,$server->create("tenpct",\@fields,[])); +do_many($dbh,$server->create("tiny",["col_key int not null"],[])); + +print "Start AS3AP benchmark\n\n"; + +$start_time=new Benchmark; + +print "Load DATA\n"; +#Load DATA + +@table_names=("uniques","updates","hundred","tenpct","tiny"); + +$loop_time=new Benchmark; + +if ($opt_fast && $server->{'limits'}->{'load_data_infile'}) +{ + for ($ti = 0; $ti <= $#table_names; $ti++) + { + my $table_name = $table_names[$ti]; + my $file = "$pwd/Data/AS3AP/${table_name}\.new"; + print "$table_name - $file\n" if ($opt_debug); + $row_count += $server->insert_file($table_name,$file,$dbh); + } +} +else +{ + for ($ti = 0; $ti <= $#table_names; $ti++) + { + my $table_name = $table_names[$ti]; + print "$table_name - $file\n" if ($opt_debug); + my $insert_start = "insert into $table_name values ("; + open(DATA, "$pwd/Data/AS3AP/${table_name}\.new") || die "Can't open text file: $pwd/Data/AS3AP/${table_name}\.new\n"; + while(<DATA>) + { + chomp; + next unless ( $_ =~ /\w/ ); # skip blank lines + $command = $insert_start."$_".")"; + $command =~ $server->fix_to_insert($command); + print "$command\n" if ($opt_debug); + $sth = $dbh->do($command) or die "Got error: $DBI::errstr when executing '$command'\n"; + $row_count++; + } + close(DATA); + } +} + +$end_time=new Benchmark; +print "Time for Load Data - " . "($row_count): " . +timestr(timediff($end_time, $loop_time),"all") . "\n\n"; + + +print "Create Index\n"; + +test_command("create_idx_uniques_key_bt", + "time for create_idx_uniques_key_bt", + "create unique index uniques_key_bt on uniques (col_key)",$dbh,$opt_loop_count); + +test_command("create_idx_updates_key_bt", + "time for create_idx_updates_key_bt", + "create unique index updates_key_bt on updates (col_key)",$dbh,$opt_loop_count); + +test_command("create_idx_hundred_key_bt", + "time for create_idx_hundred_key_bt", + "create unique index hundred_key_bt on hundred (col_key)", + $dbh,$opt_loop_count); + +test_command("create_idx_tenpct_key_bt", + "time for create_idx_tenpct_key_bt", + "create unique index tenpct_key_bt on tenpct (col_key)",$dbh,$opt_loop_count); + +test_command("create_idx_tenpct_key_code_bt", + "time for create_idx_tenpct_key_code_bt", + "create index tenpct_key_code_bt on tenpct (col_key,col_code)", + $dbh,$opt_loop_count); + +test_command("create_idx_tiny_key_bt", + "time for create_idx_tiny_key_bt", + "create index tiny_key_bt on tiny (col_key)",$dbh,$opt_loop_count); + +test_command("create_idx_tenpct_int_bt", + "time for create_idx_tenpct_int_bt", + "create index tenpct_int_bt on tenpct (col_int)",$dbh,$opt_loop_count); + +test_command("create_idx_tenpct_signed_bt", + "time for create_idx_tenpct_signed_bt", + "create index tenpct_signed_bt on tenpct (col_signed)",$dbh,$opt_loop_count); + +test_command("create_idx_uniques_code_h", + "time for create_idx_uniques_code_h", + "create index uniques_code_h on uniques (col_code)",$dbh,$opt_loop_count); + +test_command("create_idx_tenpct_double_bt", + "time for create_idx_tenpct_double_bt", + "create index tenpct_double_bt on tenpct (col_double)",$dbh,$opt_loop_count); + + +test_command("create_idx_updates_decim_bt", + "time for create_idx_updates_decim_bt", + "create index updates_decim_bt on updates (col_decim)",$dbh,$opt_loop_count); + +test_command("create_idx_tenpct_float_bt", + "time for create_idx_tenpct_float_bt", + "create index tenpct_float_bt on tenpct (col_float)",$dbh,$opt_loop_count); + +test_command("create_idx_updates_int_bt", + "time for create_idx_updates_int_bt", + "create index updates_int_bt on updates (col_int)",$dbh,$opt_loop_count); + +test_command("create_idx_tenpct_decim_bt", + "time for create_idx_tenpct_decim_bt", + "create index tenpct_decim_bt on tenpct (col_decim)",$dbh,$opt_loop_count); + +test_command("create_idx_hundred_code_h", + "time for create_idx_hundred_code_h", + "create index hundred_code_h on hundred (col_code)",$dbh,$opt_loop_count); + +test_command("create_idx_tenpct_name_h", + "time for create_idx_tenpct_name_h", + "create index tenpct_name_h on tenpct (col_name)",$dbh,$opt_loop_count); + +test_command("create_idx_updates_code_h", + "time for create_idx_updates_code_h", + "create index updates_code_h on updates (col_code)",$dbh,$opt_loop_count); + +test_command("create_idx_tenpct_code_h", + "time for create_idx_tenpct_code_h", + "create index tenpct_code_h on tenpct (col_code)",$dbh,$opt_loop_count); + +test_command("create_idx_updates_double_bt", + "time for create_idx_updates_double_bt", + "create index updates_double_bt on updates (col_double)",$dbh,$opt_loop_count); + +test_command("create_idx_hundred_foreign", + "time for create_idx_hundred_foreign", + "alter table hundred add constraint fk_hundred_updates foreign key (col_signed) + references updates (col_key)",$dbh,$opt_loop_count); + +test_query("sel_1_cl", + "Time to sel_1_cl", + "select col_key, col_int, col_signed, col_code, col_double, col_name + from updates where col_key = 1000",$dbh,$opt_loop_count); + +test_query("join_3_cl", + "Time to join_3_cl", + "select uniques.col_signed, uniques.col_date, + hundred.col_signed, hundred.col_date, + tenpct.col_signed, tenpct.col_date + from uniques, hundred, tenpct + where uniques.col_key = hundred.col_key + and uniques.col_key = tenpct.col_key + and uniques.col_key = 1000",$dbh,$opt_loop_count); + +test_query("sel_100_ncl", + "Time to sel_100_ncl", + "select col_key, col_int, col_signed, col_code,col_double, col_name + from updates where col_int <= 100",$dbh,$opt_loop_count); + +test_query("table_scan", + "Time to table_scan", + "select * from uniques where col_int = 1",$dbh,$opt_loop_count); + +test_query("agg_func", + "Time for agg_func", + "select min(col_key) from hundred group by col_name",$dbh,$opt_loop_count); + +test_query("agg_scal", + "Time for agg_scal", + "select min(col_key) from uniques",$dbh,$opt_loop_count); + +test_query("sel_100_cl", + "Time for sel_100_cl", + "select col_key, col_int, col_signed, col_code, + col_double, col_name + from updates where col_key <= 100",$dbh,$opt_loop_count); + +test_query("join_3_ncl", + "Time for join_3_ncl", + "select uniques.col_signed, uniques.col_date, + hundred.col_signed, hundred.col_date, + tenpct.col_signed, tenpct.col_date + from uniques, hundred, tenpct + where uniques.col_code = hundred.col_code + and uniques.col_code = tenpct.col_code + and uniques.col_code = 'BENCHMARKS'",$dbh,$opt_loop_count); + +test_query("sel_10pct_ncl", + "Time for sel_10pct_ncl", + "select col_key, col_int, col_signed, col_code, + col_double, col_name + from tenpct + where col_name = 'THE+ASAP+BENCHMARKS+'",$dbh,$opt_loop_count); + +if ($limits->{'subqueries'}){ + test_query("agg_simple_report", + "Time for agg_simple_report", + "select avg(updates.col_decim) + from updates + where updates.col_key in + (select updates.col_key + from updates, hundred + where hundred.col_key = updates.col_key + and updates.col_decim > 980000000)",$dbh,$opt_loop_count); +}else{ + print "agg_simple_report - Failed\n\n"; +} + +test_query("agg_info_retrieval", + "Time for agg_info_retrieval", + "select count(col_key) + from tenpct + where col_name = 'THE+ASAP+BENCHMARKS' + and col_int <= 100000000 + and col_signed between 1 and 99999999 + and not (col_float between -450000000 and 450000000) + and col_double > 600000000 + and col_decim < -600000000",$dbh,$opt_loop_count); + +if ($limits->{'views'}){ + test_query("agg_create_view", + "Time for agg_create_view", + "create view + reportview(col_key,col_signed,col_date,col_decim, + col_name,col_code,col_int) as + select updates.col_key, updates.col_signed, + updates.col_date, updates.col_decim, + hundred.col_name, hundred.col_code, + hundred.col_int + from updates, hundred + where updates.col_key = hundred.col_key",$dbh,$opt_loop_count); + + test_query("agg_subtotal_report", + "Time for agg_subtotal_report", + "select avg(col_signed), min(col_signed), max(col_signed), + max(col_date), min(col_date), + count(distinct col_name), count(col_name), + col_code, col_int + from reportview + where col_decim >980000000 + group by col_code, col_int",$dbh,$opt_loop_count); + + + test_query("agg_total_report", + "Time for agg_total_report", + "select avg(col_signed), min(col_signed), max(col_signed), + max(col_date), min(col_date), + count(distinct col_name), count(col_name), + count(col_code), count(col_int) + from reportview + where col_decim >980000000",$dbh,$opt_loop_count); +}else{ + print "agg_create_view - Failed\n\n"; + print "agg_subtotal_report - Failed\n\n"; + print "agg_total_report - Failed\n\n"; +} + +#fix from here +test_query("join_2_cl", + "Time for join_2_cl", + "select uniques.col_signed, uniques.col_name, + hundred.col_signed, hundred.col_name + from uniques, hundred + where uniques.col_key = hundred.col_key + and uniques.col_key =1000" + ,$dbh,$opt_loop_count); + +test_query("join_2", + "Time for join_2", + "select uniques.col_signed, uniques.col_name, + hundred.col_signed, hundred.col_name + from uniques, hundred + where uniques.col_address = hundred.col_address + and uniques.col_address = 'SILICON VALLEY'" + ,$dbh,$opt_loop_count); + +test_query("sel_variable_select_low", + "Time for sel_variable_select_low", + "select col_key, col_int, col_signed, col_code, + col_double, col_name + from tenpct + where col_signed < -500000000" + ,$dbh,$opt_loop_count); + +test_query("sel_variable_select_high", + "Time for sel_variable_select_high", + "select col_key, col_int, col_signed, col_code, + col_double, col_name + from tenpct + where col_signed < -250000000" + ,$dbh,$opt_loop_count); + +test_query("join_4_cl", + "Time for join_4_cl", + "select uniques.col_date, hundred.col_date, + tenpct.col_date, updates.col_date + from uniques, hundred, tenpct, updates + where uniques.col_key = hundred.col_key + and uniques.col_key = tenpct.col_key + and uniques.col_key = updates.col_key + and uniques.col_key = 1000" + ,$dbh,$opt_loop_count); + +test_query("proj_100", + "Time for proj_100", + "select distinct col_address, col_signed from hundred" + ,$dbh,$opt_loop_count); + +test_query("join_4_ncl", + "Time for join_4_ncl", + "select uniques.col_date, hundred.col_date, + tenpct.col_date, updates.col_date + from uniques, hundred, tenpct, updates + where uniques.col_code = hundred.col_code + and uniques.col_code = tenpct.col_code + and uniques.col_code = updates.col_code + and uniques.col_code = 'BENCHMARKS'" + ,$dbh,$opt_loop_count); + +test_query("proj_10pct", + "Time for proj_10pct", + "select distinct col_signed from tenpct" + ,$dbh,$opt_loop_count); + +test_query("sel_1_ncl", + "Time for sel_1_ncl", + "select col_key, col_int, col_signed, col_code, + col_double, col_name + from updates where col_code = 'BENCHMARKS'" + ,$dbh,$opt_loop_count); + +test_query("join_2_ncl", + "Time for join_2_ncl", + "select uniques.col_signed, uniques.col_name, + hundred.col_signed, hundred.col_name + from uniques, hundred + where uniques.col_code = hundred.col_code + and uniques.col_code = 'BENCHMARKS'" + ,$dbh,$opt_loop_count); + +if ($limits->{'foreign_key'}){ + do_many($dbh,$server->create("integrity_temp",\@fields,[])); + + test_query("integrity_test_1", + "Time for integrity_test", + "insert into integrity_temp select * + from hundred where col_int=0",$dbh,$opt_loop_count); + + test_query("integrity_test_2", + "Time for integrity_test", + "update hundred set col_signed = '-500000000' + where col_int = 0",$dbh,$opt_loop_count); + + test_query("integrity_test_3", + "Time for integrity_test", + "update hundred set col_signed = '-500000000' + where col_int = 0",$dbh,$opt_loop_count); + + +}else{ + print "integrity_test - Failed\n\n"; +} + +push @drop_seq_command,$server->drop_index("updates","updates_int_bt"); +push @drop_seq_command,$server->drop_index("updates","updates_double_bt"); +push @drop_seq_command,$server->drop_index("updates","updates_decim_bt"); +push @drop_seq_command,$server->drop_index("updates","updates_code_h"); + +test_many_command("Drop updates keys", + "Time for drop_updates_keys", + \@drop_seq_command,$dbh,$opt_loop_count); + +do_many($dbh,$server->create("saveupdates",\@fields,[])); + +test_command("bulk_save", + "Time for bulk_save", + "insert into saveupdates select * + from updates where col_key between 5000 and 5999" + ,$dbh,$opt_loop_count); + +test_command("bulk_modify", + "Time for bulk_modify", + "update updates + set col_key = col_key - 100000 + where col_key between 5000 and 5999" + ,$dbh,$opt_loop_count); + +safe_command("upd_append_duplicate", + "Time for upd_append_duplicate", + "insert into updates + values (6000, 0, 60000, 39997.90, + 50005.00, 50005.00, + '11/10/1985', 'CONTROLLER', + 'ALICE IN WONDERLAND', + 'UNIVERSITY OF ILLINOIS AT CHICAGO')" + ,$dbh,$opt_loop_count); + +test_command("upd_remove_duplicate", + "Time for upd_remove_duplicate", + "delete from updates where col_key = 6000 and col_int = 0" + ,$dbh,$opt_loop_count); + +test_command("upd_app_t_mid", + "Time for upd_app_t_mid", + "insert into updates + values (5005, 5005, 50005, 50005.00, 50005.00, + 50005.00, '1/1/1988', 'CONTROLLER', + 'ALICE IN WONDERLAND', + 'UNIVERSITY OF ILLINOIS AT CHICAGO')" + ,$dbh,$opt_loop_count); + +test_command("upd_mod_t_mid", + "Time for upd_mod_t_mid", + "update updates set col_key = '-5000' + where col_key = 5005" + ,$dbh,$opt_loop_count); + +test_command("upd_del_t_mid", + "Time for upd_del_t_mid", + "delete from updates + where (col_key='5005') or (col_key='-5000')" + ,$dbh,$opt_loop_count); + +test_command("upd_app_t_end", + "Time for upd_app_t_end", + "delete from updates + where (col_key='5005') or (col_key='-5000')" + ,$dbh,$opt_loop_count); + +test_command("upd_mod_t_end", + "Time for upd_mod_t_end", + "update updates + set col_key = -1000 + where col_key = 1000000001" + ,$dbh,$opt_loop_count); + +test_command("upd_del_t_end", + "Time for upd_del_t_end", + "delete from updates where col_key = -1000" + ,$dbh,$opt_loop_count); + +test_command("create_idx_updates_code_h", + "time for create_idx_updates_code_h", + "create index updates_code_h on updates (col_code)", + $dbh,$opt_loop_count); + +test_command("upd_app_t_mid", + "Time for upd_app_t_mid", + "insert into updates + values (5005, 5005, 50005, 50005.00, 50005.00, + 50005.00, '1/1/1988', 'CONTROLLER', + 'ALICE IN WONDERLAND', + 'UNIVERSITY OF ILLINOIS AT CHICAGO')" + ,$dbh,$opt_loop_count); + +test_command("upd_mod_t_cod", + "Time for upd_mod_t_cod", + "update updates + set col_code = 'SQL+GROUPS' + where col_key = 5005" + ,$dbh,$opt_loop_count); + +test_command("upd_del_t_mid", + "Time for upd_del_t_mid", + "delete from updates + where (col_key='5005') or (col_key='-5000')" + ,$dbh,$opt_loop_count); + +test_command("create_idx_updates_int_bt", + "time for create_idx_updates_int_bt", + "create index updates_int_bt on updates (col_int)", + $dbh,$opt_loop_count); + +test_command("upd_app_t_mid", + "Time for upd_app_t_mid", + "insert into updates + values (5005, 5005, 50005, 50005.00, 50005.00, + 50005.00, '1/1/1988', 'CONTROLLER', + 'ALICE IN WONDERLAND', + 'UNIVERSITY OF ILLINOIS AT CHICAGO')" + ,$dbh,$opt_loop_count); + +test_command("upd_mod_t_int", + "Time for upd_mod_t_int", + "update updates set col_int = 50015 where col_key = 5005" + ,$dbh,$opt_loop_count); + +test_command("upd_del_t_mid", + "Time for upd_del_t_mid", + "delete from updates + where (col_key='5005') or (col_key='-5000')" + ,$dbh,$opt_loop_count); + +test_command("bulk_append", + "Time for bulk_append", + "insert into updates select * from saveupdates" + ,$dbh,$opt_loop_count); + +test_command("bulk_delete", + "Time for bulk_delete", + "delete from updates where col_key < 0" + ,$dbh,$opt_loop_count); + +################################ END ################################### +#### +#### End of the test...Finally print time used to execute the +#### whole test. + +$dbh->disconnect; + +end_benchmark($start_time); + +############################ HELP FUNCTIONS ############################## + +sub test_query +{ + my($test_text,$result_text,$query,$dbh,$count)=@_; + my($i,$loop_time,$end_time); + + print $test_text . "\n"; + $loop_time=new Benchmark; + for ($i=0 ; $i < $count ; $i++) + { + defined(fetch_all_rows($dbh,$query)) or warn $DBI::errstr; + } + $end_time=new Benchmark; + print $result_text . "($count): " . + timestr(timediff($end_time, $loop_time),"all") . "\n\n"; +} + + +sub test_command +{ + my($test_text,$result_text,$query,$dbh,$count)=@_; + my($i,$loop_time,$end_time); + + print $test_text . "\n"; + $loop_time=new Benchmark; + for ($i=0 ; $i < $count ; $i++) + { + $dbh->do($query) or die $DBI::errstr; + } + $end_time=new Benchmark; + print $result_text . "($count): " . + timestr(timediff($end_time, $loop_time),"all") . "\n\n"; +} + +sub safe_command +{ + my($test_text,$result_text,$query,$dbh,$count)=@_; + my($i,$loop_time,$end_time); + + print $test_text . "\n"; + $loop_time=new Benchmark; + for ($i=0 ; $i < $count ; $i++) + { + safe_do_many($dbh,$query); + } + $end_time=new Benchmark; + print $result_text . "($count): " . + timestr(timediff($end_time, $loop_time),"all") . "\n\n"; +} + +sub test_many_command +{ + my($test_text,$result_text,$query,$dbh,$count)=@_; + my($i,$loop_time,$end_time); + + $loop_time=new Benchmark; + for ($i=0 ; $i < $count ; $i++) + { + safe_do_many($dbh, @$query); + } + $end_time=new Benchmark; + print $result_text . "($count): " . + timestr(timediff($end_time, $loop_time),"all") . "\n\n"; +} + + diff --git a/sql-bench/run-all-tests.sh b/sql-bench/run-all-tests.sh index c2f687a9375..eb07d85be03 100644 --- a/sql-bench/run-all-tests.sh +++ b/sql-bench/run-all-tests.sh @@ -195,6 +195,10 @@ while (<test-*>) print "Summary for $prog: ", join(" ",@prog_sum), "\n"; } } + elsif ($last_line =~ /^Test skipped/i) + { + print "$last_line\n"; + } else { $errors++; diff --git a/sql-bench/server-cfg.sh b/sql-bench/server-cfg.sh index 4dd762a804b..1e755be8f43 100644 --- a/sql-bench/server-cfg.sh +++ b/sql-bench/server-cfg.sh @@ -121,7 +121,7 @@ sub new $self->{'double_quotes'} = 1; # Can handle: 'Walker''s' $self->{'vacuum'} = 1; # When using with --fast $self->{'drop_attr'} = ""; - $self->{'transactions'} = 1; # Transactions enabled + $self->{'transactions'} = 0; # Transactions disabled by default $limits{'NEG'} = 1; # Supports -id $limits{'alter_add_multi_col'}= 1; #Have ALTER TABLE t add a int,add b int; @@ -197,12 +197,14 @@ sub new $main::opt_create_options =~ /type=innodb/i) { $limits{'max_text_size'} = 8000; # Limit in Innobase + $self->{'transactions'} = 1; # Transactions enabled } if (defined($main::opt_create_options) && $main::opt_create_options =~ /type=gemini/i) { $limits{'working_blobs'} = 0; # Blobs not implemented yet $limits{'max_tables'} = 500; + $self->{'transactions'} = 1; # Transactions enabled } return $self; @@ -1333,6 +1335,14 @@ sub query { return $sql; } +sub fix_for_insert +{ + my ($self,$cmd) = @_; + $cmd =~ s/\'\'/\' \'/g; + return $cmd; +} + + sub drop_index { my ($self,$table,$index) = @_; @@ -1556,6 +1566,14 @@ sub query { return $sql; } +sub fix_for_insert +{ + my ($self,$cmd) = @_; + $cmd =~ s/\'\'/\' \'/g; + return $cmd; +} + + sub drop_index { my ($self,$table,$index) = @_; @@ -1789,6 +1807,16 @@ sub query { return $sql; } + +sub fix_for_insert +{ + my ($self,$cmd) = @_; + $cmd =~ s/\\'//g; + return $cmd; +} + + + sub drop_index { my ($self,$table,$index) = @_; diff --git a/sql-bench/test-ATIS.sh b/sql-bench/test-ATIS.sh index fa66dadd03e..da866f2eb66 100644 --- a/sql-bench/test-ATIS.sh +++ b/sql-bench/test-ATIS.sh @@ -125,8 +125,7 @@ if (!$opt_skip_create) chomp; next unless ( $_ =~ /\w/ ); # skip blank lines my $command = $insert_start . $_ . ")"; - $command =~ s/\'\'/\' \'/g if ($opt_server =~ /empress/i || $opt_server =~ /oracle/i); - $command =~ s/\\'//g if ($opt_server =~ /informix/i); + $command = $server->fix_for_insert($command); print "$command\n" if ($opt_debug); $command =~ s/\\'/\'\'/g if ($double_quotes); diff --git a/sql-bench/test-transactions.sh b/sql-bench/test-transactions.sh new file mode 100644 index 00000000000..62de009ab33 --- /dev/null +++ b/sql-bench/test-transactions.sh @@ -0,0 +1,268 @@ +#!@PERL@ +# +# Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Library General Public +# License as published by the Free Software Foundation; either +# version 2 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Library General Public License for more details. +# +# You should have received a copy of the GNU Library General Public +# License along with this library; if not, write to the Free +# Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, +# MA 02111-1307, USA +# +# Test of transactions performance. +# + +##################### Standard benchmark inits ############################## + +use DBI; +use Benchmark; +use warnings; + +$opt_groups=27; # Characters are 'A' -> Z + +$opt_loop_count=100000; # Change this to make test harder/easier +$opt_medium_loop_count=100; # Change this to make test harder/easier + +chomp($pwd = `pwd`); $pwd = "." if ($pwd eq ''); +require "$pwd/bench-init.pl" || die "Can't read Configuration file: $!\n"; + +# Avoid warnings for variables in bench-init.pl +our ($opt_small_test, $opt_small_tables, $opt_debug, $opt_force); + +if ($opt_small_test || $opt_small_tables) +{ + $opt_loop_count/=100; + $opt_medium_loop_count/=10; +} + + +if (!$server->{transactions} && !$opt_force) +{ + print "Test skipped because the database doesn't support transactions\n"; + exit(0); +} + +#### +#### Connect and start timeing +#### + +$start_time=new Benchmark; +$dbh = $server->connect(); + +### +### Create Table +### + +print "Creating tables\n"; +$dbh->do("drop table bench1"); +$dbh->do("drop table bench2"); + +do_many($dbh,$server->create("bench1", + ["idn int NOT NULL", + "rev_idn int NOT NULL", + "region char(1) NOT NULL", + "grp int NOT NULL", + "updated tinyint NOT NULL"], + ["primary key (idn)", + "unique (region,grp)"])); +do_many($dbh,$server->create("bench2", + ["idn int NOT NULL", + "rev_idn int NOT NULL", + "region char(1) NOT NULL", + "grp int NOT NULL", + "updated tinyint NOT NULL"], + ["primary key (idn)", + "unique (region,grp)"])); + +$dbh->{AutoCommit} = 0; + +### +### Test insert perfomance +### + +test_insert("bench1","insert_commit",0); +test_insert("bench2","insert_autocommit",1); + +sub test_insert +{ + my ($table, $test_name, $auto_commit)= @_; + my ($loop_time,$end_time,$id,$rev_id,$grp,$region); + + $dbh->{AutoCommit}= $auto_commit; + $loop_time=new Benchmark; + + for ($id=0,$rev_id=$opt_loop_count-1 ; $id < $opt_loop_count ; + $id++,$rev_id--) + { + $grp=$id/$opt_groups; + $region=chr(65+$id%$opt_groups); + do_query($dbh,"insert into $table values ($id,$rev_id,'$region',$grp,0)"); + } + + $dbh->commit if (!$auto_commit); + $end_time=new Benchmark; + print "Time for $test_name ($opt_loop_count): " . + timestr(timediff($end_time, $loop_time),"all") . "\n\n"; +} + +### +### Test update perfomance +### + +test_update("bench1","update_commit",0); +test_update("bench2","update_autocommit",1); + +sub test_update +{ + my ($table, $test_name, $auto_commit)= @_; + my ($loop_time,$end_time,$id); + + $dbh->{AutoCommit}= $auto_commit; + $loop_time=new Benchmark; + + for ($id=0 ; $id < $opt_loop_count ; $id++) + { + do_query($dbh,"update bench1 set updated=1 where idn=$id"); + } + + $dbh->commit if (!$auto_commit); + $end_time=new Benchmark; + print "Time for $test_name ($opt_loop_count): " . + timestr(timediff($end_time, $loop_time),"all") . "\n\n"; +} + +### +### Test delete perfomance +### + +test_delete("bench1","delete_commit",0); +test_delete("bench2","delete_autocommit",1); + +sub test_delete +{ + my ($table, $test_name, $auto_commit)= @_; + my ($loop_time,$end_time,$id); + + $dbh->{AutoCommit}= $auto_commit; + $loop_time=new Benchmark; + + for ($id=0 ; $id < $opt_loop_count ; $id++) + { + do_query($dbh,"delete from $table where idn=$id"); + } + $dbh->commit if (!$auto_commit); + $end_time=new Benchmark; + print "Time for $test_name ($opt_loop_count): " . + timestr(timediff($end_time, $loop_time),"all") . "\n\n"; +} + +### +### Test rollback performance +### + +print "Test transactions rollback performance\n" if($opt_debug); + +## +## Insert rollback test +## + +# +# Test is done by inserting 10 rows in a table with lots of rows and +# then doing a rollback on these +# + +{ + my ($id,$rev_id,$grp,$region,$end,$loop_time,$end_time,$commit_loop,$count); + + $dbh->{AutoCommit} = 0; + $loop_time=new Benchmark; + $end=$opt_loop_count*2; + $count=0; + + for ($commit_loop=1, $id=$opt_loop_count ; $id < $end ; + $id++, $commit_loop++) + { + $rev_id=$end-$id; + $grp=$id/$opt_groups; + $region=chr(65+$id%$opt_groups); + do_query($dbh,"insert into bench1 values ($id,$rev_id,'$region',$grp,0)"); + if ($commit_loop >= $opt_medium_loop_count) + { + $dbh->rollback; + $commit_loop=0; + $count++; + } + } + if ($commit_loop > 1) + { + $dbh->rollback; + $count++; + } + $end_time=new Benchmark; + print "Time for insert_rollback ($count:$opt_loop_count): " . + timestr(timediff($end_time, $loop_time),"all") . "\n\n"; +} + +### +### Update rollback test +### + +if (0) +{ + + $dbh->{AutoCommit} = 0; + + $loop_time=new Benchmark; + + for ($id=0,$rev_id=$opt_medium_loop_count ; $id < $opt_medium_loop_count; $id++,$rev_id--) + { + $grp=$id/$opt_groups; + $region=chr(65+$id%$opt_groups); + do_query($dbh,"update bench1 set region='$region',grp=$grp where idn=$id"); + } + + $dbh->rollback; + + $end_time=new Benchmark; + print "Time for update rollback (" . ($opt_medium_loop_count) . "): " . + timestr(timediff($end_time, $loop_time),"all") . "\n\n"; + +### Delete rollback test + $dbh->{AutoCommit} = 0; + + $loop_time=new Benchmark; + + for ($id=0,$rev_id=$opt_medium_loop_count; $id < $opt_medium_loop_count; $id++,$rev_id--) + { + $grp=$id/$opt_groups; + $region=chr(65+$id%$opt_groups); + do_query($dbh,"delete from bench1 where idn=$id"); + } + + $dbh->rollback; + + $end_time=new Benchmark; + print "Time for delete rollback (" . ($opt_medium_loop_count) . "): " . + timestr(timediff($end_time, $loop_time),"all") . "\n\n"; + + $dbh->{AutoCommit} = 1; +} + + +#### +#### End of benchmark +#### + +$sth = $dbh->do("drop table bench1" . $server->{'drop_attr'}) or die $DBI::errstr; +$sth = $dbh->do("drop table bench2" . $server->{'drop_attr'}) or die $DBI::errstr; + +$dbh->disconnect; # close connection +end_benchmark($start_time); |