#!/usr/bin/perl -w use strict; use DBI; my $dbh = DBI->connect("dbi:driver:database", "user","password",{RaiseError=>1}) or die; $dbh->do(qq{ create table sequence (id int not null primary key)) }); my $sth = $dbh->prepare(qq{ insert into sequence values (?) }); $dbh->{autocommit} =0; $dbh->begin; for ( 1.. 1_200_000) { $sth->execute($_); if (($_ % 1000) == 0) { $dbh->commit; $dbh->begin; } } $dbh->commit; my $min = 968000; my $max = 1029829; my $sequence_query = qq{ SELECT a.id FROM sequence a LEFT JOIN Transaction b ON (a.id=b.TranstactionID) WHERE a.id BETWEEN $min AND $max AND b.TranstactionID IS NULL }; $sth = $dbh->prepare($sequence_query); $sth->execute(); while (my ($row) = $sth->fetchrow_array) { print "$row is missing \n"; } $dbh->disconnect();