Thread mass-inserts: performance problem (3 answers)
Opened by cubecolon at 2011-10-13 21:11

cubecolon
 2011-10-13 21:11
#153198 #153198
User since
2011-10-13
2 Artikel
BenutzerIn
[default_avatar]
Hallo zusammen,

beim Insert von 500k+ Datensätzen in eine Tabelle unter Informix ist u.g. code ca. 6x langsamer als mit "load from insert into" mit dbaccess client.

Gibt es eine Möglichkeit, den Code performanter zu gestalten?

Vielen Dank!

Code: (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
my $dbh = DBI->connect("dbi:Informix:$db\@$server", "$user", "$pw");

$dbh->{ix_WithoutReplication} = 1;
$dbh->{AutoCommit} = 0;

$sth = $dbh->prepare('BEGIN WORK') or die $DBI::errstr."\n";
$sth->execute();

undef $sth;
open(loadfile,"<data.unl");

foreach $line (<loadfile>)
{
chomp();
@all_cols = split(/\\|/,$line);

if (! defined $sth) # is executed only one time
{
$sth = $dbh->prepare_cached("INSERT INTO mytable VALUES(?,?,?,?,?)") or die "Error: ".$DBI::errstr."\n";
}

$sth->execute(@all_cols) or die "Error: \"".$DBI::errstr."\"\n";
$x++;
}

$sth = $dbh->prepare('COMMIT WORK') or die "Error: ".$DBI::errstr."\n";
$sth->execute();

Last edited: 2011-10-13 21:33:32 +0200 (CEST)

View full thread mass-inserts: performance problem