MySQL Forums
Forum List  »  Perl

how to speedup mysql queries?
Posted by: Rytis Diciunas
Date: October 19, 2006 04:55AM

Hello, i have 1 problem, i have 2 arrays, and want to check it values in mysql database,
this script works well, but when here is 30000 and more queries it works very slow....
takes 5-10 minutes...Maybe here i need write some trigger? or hese is another way?


foreach $c1(@c1) {
foreach $c2(@c2)
{
$sth = $dbh->prepare( "SELECT a.id FROM a, a_b, b WHERE a.id = '$c1 AND .....')
or die "Can't prepare SQL statement: $DBI::errstr\n";
$sth->execute;
$row = $sth->fetchrow();
$sth = $dbh->prepare( "SELECT a.id FROM a, a_b, b WHERE a.id = '$c2' AND....)
or die "Can't prepare SQL statement: $DBI::errstr\n";

$sth->execute;
$row1 = $sth->fetchrow( );

if ($row == $row1)
{
push @row3, $row
}






}
}



Edited 1 time(s). Last edit at 10/19/2006 07:25AM by Rytis Diciunas.

Options: ReplyQuote


Subject
Written By
Posted
how to speedup mysql queries?
October 19, 2006 04:55AM
October 20, 2006 02:13AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.