leostereo has asked for the wisdom of the Perl Monks concerning the following question:
Hi guys , I need to move big databa among databases.
I have been reading about improving performance with mysql prepared statements.
So far I dont understand why it is better neither how to use it.
Lets suppose I have the following "bring and insert data" procedure:
#!/usr/bin/perl use strict; use warnings; require DBI; ### #variables here my @big_data_array; ### foreach $id (@big_data_array){ $query1 = "SELECT * from database1.table WHERE id = '$ +id' my $sth1 = $dbh1->prepare($query1); $sth2->execute(); while (my @row = $sth1->fetchrow_array ) { $val1 = $row[0]; $val2=$row[1]; } $query2 = "insert into database2.table ('value1','valu +e2')". " VALUES('$val1','$val2')"; my $sth2 = $dbh2->prepare($query2); $sth2->execute(); }
Question is how to achieve same result using prepared statements ?
And why is it better ?
I will try to find more info about it.
Regards,
Leo.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: dbi: moving big data among databases (prepared statements)
by atcroft (Abbot) on Jun 16, 2018 at 18:25 UTC | |
by Anonymous Monk on Jun 16, 2018 at 19:00 UTC | |
|
Re: dbi: moving big data among databases (prepared statements)
by AnomalousMonk (Archbishop) on Jun 16, 2018 at 18:20 UTC | |
|
Re: dbi: moving big data among databases (prepared statements)
by nikosv (Deacon) on Jun 16, 2018 at 22:22 UTC | |
|
Re: dbi: moving big data among databases (prepared statements)
by clueless newbie (Curate) on Jun 17, 2018 at 12:51 UTC | |
| A reply falls below the community's threshold of quality. You may see it by logging in. |