Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
It looks to me like the databasing is the rate limiting step because when I run the program the cpu usage is about 60% while disk IO is going crazy.
I crave the benefit of your experience.
Code follows:
sub insert_nodes_one { my $sth = $dbh->prepare_cached("INSERT INTO node (taxid, name, tre +e_id, parent, children, rank, common_name) VALUES (?, ?, '4', '-1', 'replace me', ?, ?); ") or die "Cannot prepare: " . $dbh->errstr(); foreach (keys %tax_lookup) { first_pass($_, $sth, \$n, $count); } } sub first_pass{ my $key = $_[0]; my $sth = $_[1]; my $n= $_[2]; my $count= $_[3]; my $name = $tax_lookup{$key}{name}; $name =~ s/'/_/g; my $common_name = $tax_lookup{$key}{common_name}; $common_name = 'none' unless ($common_name); $common_name =~ s/'/_/g; my $parent_taxid = $tax_lookup{$key}{parent_taxid}; my $rank = $tax_lookup{$key}{rank}; if ($tax_lookup{$key}{rank} eq 'no') {$rank = 'none'} my $children_taxid = join ' ', @{$tax_lookup{$key}{children_ta +xid}}; unless ($$n % 100) {print "\r($$n / $count)"} $sth->execute($key, $name, $rank, $common_name); $$n++; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Quickest way to insert many rows with DBI
by borisz (Canon) on Apr 11, 2006 at 09:41 UTC | |
|
Re: Quickest way to insert many rows with DBI
by holli (Abbot) on Apr 11, 2006 at 09:41 UTC | |
by Anonymous Monk on Apr 11, 2006 at 09:51 UTC | |
by rinceWind (Monsignor) on Apr 11, 2006 at 09:57 UTC | |
|
Re: Quickest way to insert many rows with DBI
by merlyn (Sage) on Apr 11, 2006 at 12:20 UTC | |
|
Re: Quickest way to insert many rows with DBI
by Anonymous Monk on Apr 11, 2006 at 11:25 UTC | |
|
Re: Quickest way to insert many rows with DBI
by tweetiepooh (Hermit) on Apr 11, 2006 at 10:19 UTC | |
|
Re: Quickest way to insert many rows with DBI
by Herkum (Parson) on Apr 11, 2006 at 12:18 UTC | |
|