Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling

comment on


I'm doing a query that returns many rows, using DBI and DBD::mysql. I expect the $sth->execute to get the query started and return almost immediately, and then one of the fetchrow methods to actually get the results. Instead, execute seems to gather all of the results before returning, taking a long time to finish and using up over 1GB of memory.

Is there a way to work around this?

Here's my code. It gets to "Executing..." and then sits there for a very long time taking up memory; based on other tests it will eventually return, and after that the fetchrows will work.

#!/usr/bin/perl -w BEGIN { $ENV{MYSQL_UNIX_PORT}='/clair8/corpora/aledb/run/socket'; }; use strict; use DBI; my $sql = "SELECT url1.urlid AS from_id, url1.url AS from_url, link1.l +ink_text AS link1_text, link1.linkid AS link1_id, url2.urlid AS to_id +, url2.url AS to_url FROM DOTGOV_links AS link1, DOTGOV_urls AS url1, DOTGOV_urls AS url2 WHERE (link1.link_from = url1.urlid) AND (link1.link_to = url2.urlid)"; warn "Connecting...\n"; my $dbh = DBI->connect('DBI:mysql:database=clair', 'root','', {AutoCom +mit => 1}) or die "Error creating dbh.\n"; warn "Connected!\n"; warn "Preparing...\n"; my $sth = $dbh->prepare($sql) or die "Error preparing sth.\n"; warn "Prepared!\n"; warn "Executing...\n"; $sth->execute or die "Error executing sth.\n"; warn "Executed!\n"; warn "Finishing...\n"; $sth->finish or die "Error finishing sth.\n"; warn "Finished!\n";

In reply to DBI/mysql gathering all rows on execute by sgifford

and:  <code> code here </code>

  • Please read these before you post! —
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Log In?

    What's my password?
    Create A New User
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others avoiding work at the Monastery: (5)
    As of 2020-01-22 03:14 GMT
    Find Nodes?
      Voting Booth?