MySQL Forums
Forum List  »  Perl

Data gets preloaded upon $sth->execute?
Posted by: Dmitry Nikiforov
Date: December 01, 2011 04:34PM


I've been working with both DBD::Oracle and DBD::mysql from my perl scripts, and noticed an odd difference between how they operate. Consider this:

my $oracle = DBI->connect( @oracle_params ) or die $DBI::errstr;
my $mysql = DBI->connect( @mysql_params ) or die $DBI::errstr;

my $query = "select * from table1";

my $sthO = $oracle->prepare( $query );
my $sthM = $mysql->prepare( $query );

Everything is simple so far. But now we do "$sthO->execute()" and then "$sthM->execute()". And this is where the weirdness begins: $sthO->execute returns immediately, while $sthM->execute takes a very long time and a lot of memory. It seems that with MySQL, the query is executed and its results are transferred from the mysql server to the script even before I start fetching the data, while with Oracle no data gets sent until I actually start fetching it with something like "while( my $row = $sthO->fetchrow_arrayref() ) {}".

Can anybody tell my _why_ MySQL sends the results in their entirety? Is there a way to prevent that from happening, and only return rows as I request them?

Regards - D.

Edited 2 time(s). Last edit at 12/01/2011 04:36PM by Dmitry Nikiforov.

Options: ReplyQuote

Written By
Data gets preloaded upon $sth->execute?
December 01, 2011 04:34PM

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.