summaryrefslogtreecommitdiff
path: root/sql-bench/test-insert.sh
diff options
context:
space:
mode:
authorunknown <monty@hundin.mysql.fi>2001-09-02 16:03:37 +0300
committerunknown <monty@hundin.mysql.fi>2001-09-02 16:03:37 +0300
commit992e7da03a64a12ed4bcd180dda45cb91e94a4ee (patch)
tree8e23ee5c5fb05aab08ef350c98bd7bf10f84cf47 /sql-bench/test-insert.sh
parent62c3fe9b4be15d08cd19f569eaaad495fd46a1f7 (diff)
downloadmariadb-git-992e7da03a64a12ed4bcd180dda45cb91e94a4ee.tar.gz
Added testing of IN(value-list)
Portability fixes Build-tools/Do-compile: Fix for Linux ia64 sql-bench/bench-init.pl.sh: Added help function time_fetch_all_rows sql-bench/test-insert.sh: Added testing of IN(value-list) sql/item_func.cc: Cleanup sql/mysqld.cc: Portability fix sql/stacktrace.c: Portability fix
Diffstat (limited to 'sql-bench/test-insert.sh')
-rw-r--r--sql-bench/test-insert.sh77
1 files changed, 76 insertions, 1 deletions
diff --git a/sql-bench/test-insert.sh b/sql-bench/test-insert.sh
index 9d1adda1fc3..a5d0633dbfe 100644
--- a/sql-bench/test-insert.sh
+++ b/sql-bench/test-insert.sh
@@ -1007,6 +1007,47 @@ if ($server->small_rollback_segment())
$dbh = $server->connect();
}
+###
+### Test speed of IN( value list)
+###
+
+if ($limits->{'functions'})
+{
+ if ($opt_lock_tables)
+ {
+ $sth = $dbh->do("UNLOCK TABLES") || die $DBI::errstr;
+ }
+ do_many($dbh,$server->create("bench2",
+ ["id int NOT NULL"],
+ ["primary key (id)"]));
+
+ $max_tests=min(($limits->{'query_size'}-50)/6, $opt_loop_count);
+
+ if ($opt_lock_tables)
+ {
+ $sth = $dbh->do("LOCK TABLES bench1 READ, bench2 WRITE") ||
+ die $DBI::errstr;
+ }
+ test_where_in("bench1","bench2","id",1,10);
+ test_where_in("bench1","bench2","id",11,100);
+ test_where_in("bench1","bench2","id",101,min(1000,$max_tests));
+ test_where_in("bench1","bench2","id",1000,$max_tests/2);
+ if ($max_tests > 1000)
+ {
+ test_where_in("bench1","bench2","id",$max_tests/2+1,$max_tests);
+ }
+ if ($opt_lock_tables)
+ {
+ $sth = $dbh->do("UNLOCK TABLES") || die $DBI::errstr;
+ }
+ $sth = $dbh->do("DROP TABLE bench2" . $server->{'drop_attr'}) ||
+ die $DBI::errstr;
+ if ($opt_lock_tables)
+ {
+ $sth = $dbh->do("LOCK TABLES bench1 WRITE") || die $DBI::errstr;
+ }
+}
+
####
#### Test INSERT INTO ... SELECT
####
@@ -1067,7 +1108,6 @@ if ($limits->{'insert_select'})
}
}
-
####
#### Do some deletes on the table
####
@@ -1605,3 +1645,38 @@ sub check_or_range
print " for $check ($count:$found): " .
timestr(timediff($end_time, $loop_time),"all") . "\n";
}
+
+#
+# Test if SELECT ... WHERE id in(value-list)
+#
+
+sub test_where_in
+{
+ my ($t1,$t2,$id,$from,$to)= @_;
+
+ return if ($from >= $to);
+
+ $query="SELECT $t1.* FROM $t1 WHERE $id IN (";
+ for ($i=1 ; $i <= $to ; $i++)
+ {
+ $query.="$i,";
+ }
+ $query=substr($query,0,length($query)-1) . ")";
+
+ # Fill join table to have the same id's as 'query'
+ for ($i= $from ; $i <= $to ; $i++)
+ {
+ $dbh->do("insert into $t2 values($i)") or die $DBI::errstr;
+ }
+ if ($opt_fast && defined($server->{vacuum}))
+ {
+ $server->vacuum(1,\$dbh,"bench1");
+ }
+
+ time_fetch_all_rows("\nTesting SELECT ... WHERE id in ($to values)",
+ "select_in", $query, $dbh,
+ $range_loop_count);
+ time_fetch_all_rows(undef, "select_join_in",
+ "SELECT $t1.* FROM $t1,$t2 WHERE $t1.$id=$t2.$id",
+ $dbh, $range_loop_count);
+}