
Chris Charley
User
Aug 30, 2012, 8:09 AM
Post #3 of 3
(22988 views)
|
Re: [appetitto] How to speed up module
[In reply to]
|
Can't Post
|
|
Have you set AutoCommit to '0' when you create your database handle? If not, you will be committing for every insert and this will slow it down quite a bit. You can do your inserts and commit every so many records or insert them all, then commit.
my $dbh = DBI->connect("dbi:SQLite:dbname=pedro.lite","","", {PrintError => 1, AutoCommit => 0}) or die "Can't connect"; my $sth = $dbh->prepare(q{INSERT INTO purchases VALUES(?,?,?,?)}) or die $dbh->errstr; while (<DATA>) { chomp; $sth->execute( split /\|/ ); } $dbh->commit() or die $dbh->errstr;
|