use DBI; $dbh=DBI->connect("dbi:mysql:port=9306:database=test", "root", "") or die $DBI::errstr; $total_rows=500; $duplicates=1000; print "Creating table\n"; $dbh->do("drop table if exists bench1"); $dbh->do("create table bench1 (id1 int NOT NULL, id2 int NOT NULL, dupnum int NOT NULL, index ix_id12 (id1,id2), index ix_id2 (id2)) ENGINE=Falcon"); print "Inserting in reverse order: $total_rows unique rows, $duplicates of each\n"; $query="insert into bench1 (id1,id2,dupnum) values "; for ($i=0 ; $i < $total_rows ; $i++) { for ($j=1 ; $j <= $duplicates ; $j++) { $sth = $dbh->do($query . "(" . ($total_rows-1-$i) . "," . ($total_rows-1-$i) . "," . ($j) . ")" ) or die $DBI::errstr; } } print "Retrieving inserted data from id1:\n"; $stmt=$dbh->prepare("select * from bench1 where id1=?"); $ok=0; $nok=0; for ($i=0; $i<$total_rows; $i++) { $n=$stmt->execute($i) or die $DBI::errstr; if ($n==$duplicates) { #print "ok $n\n"; $ok++; } else { print "rows for id1=$i not found but they exist $n\n"; $nok++; } } print "Retrieving inserted data from id2:\n"; $stmt=$dbh->prepare("select * from bench1 where id2=?"); $ok=0; $nok=0; for ($i=0; $i<$total_rows; $i++) { $n=$stmt->execute($i) or die $DBI::errstr; if ($n==$duplicates) { #print "ok $n\n"; $ok++; } else { print "rows for id2=$i not found but they exist $n\n"; $nok++; } } $stmt->finish(); $dbh->disconnect(); print "Total ok=$ok nok=$nok\n";