I've researched a bit and found that using mysql_use_result=1 is supposed to alleviate the memory issue. However, since I am new to this DBI module I don't understand what is happening here:
#!/usr/bin/perl -w
use strict;
use DBI;
my $dbh = DBI>connect('DBI:mysql:blah;host=blah.blah.blah.blah;mysql_use_result=1','blah','blah',{RaiseError => 1});
my $sth = $dbh->prepare('select * from TaqMinute where tradeDate<=\'2014-04-22\' and symbol<=\'AAPL\' ;') ;
if (defined($sth)) {
$sth->execute();
my @row;
while (@row = $sth-> fetchrow_array()) {
print "@row\n" ;
}
}
$sth->finish();
$dbh->disconnect
Before I added mysql_use_result=1, the script would fail after about 1.5 minutes complaining that it ran out of memory. After adding this my query arguments are ignored and I simply get all the data in the database.
Any ideas how to help me or how to use this switch properly? Btw, the database that I am querying is very large.
Thanks in advance!
Craig
$sth->finish();inside theifblock because otherwise if$sthis undef, you'll still try to call->finishagainst it.mysql_use_resultis delivering the result set without storing it in memory. Which is to say, why do you think you shouldn't be getting all the rows? Can you demonstrate that conclusively?