Re: mysql slow inserts with innodb
- From: rickyars@xxxxxxxxx
- Date: 27 Oct 2006 08:30:28 -0700
discussion and work around are discussed in the comp.lang.perl.misc
forum:
http://groups.google.com/group/comp.lang.perl.misc/browse_thread/thread/cfadcc7a1c1d748f
rickyars@xxxxxxxxx wrote:
i'm trying to insert 500k rows into a table from a comma separated text
file. unfortunately i cannot do a load data because i also need to
insert some foreign keys from another table. the following code takes
a little over 4 hours to do the insert.
several questions: is there anything glaringly wrong with my code?
please ignore typos, i removed some stuff to make it more readable.
how do i do multi value inserts in perl (i.e. 10k rows with a single
INSERT statement)?
my $select_handle =
$dbh->prepare('SELECT agent_id, agent_fullname FROM agents WHERE
agent_shortname = ? AND RDEOUTPUT_rde_id = ?');
my $insert_handle =
$dbh->prepare('INSERT INTO actual VALUES
(DEFAULT,?,?,?,?,?,?,?,?,?)');
while (<$GTRUTH>) {
chomp;
my @gtruth = split;
$select_handle->execute($gtruth[3],$rde_id);
my ($AGENTS_agent_id, $agent_fullname) = $select_handle->fetchrow;
$insert_handle->execute($AGENTS_agent_id,$rde_id,$gtruth[0],0,$gtruth[7],$gtruth[8]);
}
.
- References:
- mysql slow inserts with innodb
- From: rickyars
- mysql slow inserts with innodb
- Prev by Date: couldn't connect to database: ERROR OCIEnvInit
- Next by Date: Re: Best authentication methods for CGI <- PERL -> DBI
- Previous by thread: mysql slow inserts with innodb
- Next by thread: Trouble installing DBI without using ActiveState Repository
- Index(es):