Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

There are two possible causes, perhaps both of them at the same time:

  • If there is no index in any of link1.link_from, url1.urlid, link1.link_to, and url2.urlid, then the join takes much longer than it should. If this is the case, add an appropriate index, using an ALTER TABLE statement.
  • Your query is returning an huge amount of rows, which are clogging both your server and client memory. The reason is that MySQL default mode of fetching is All-At-Once (mysql_store_result). You can affect this behavior by setting the appropriate mode identifier after preparing the statement:
    my $sth = $dbh->prepare($sql); $sth->{"mysql_use_result"} = 1;
    Be aware that this mode requires that you either fetch all the records or use a "finish" method before issuing another request to the server.
    See MySQL manual for an explanation of this behavior (it's related to the C API) and DBD::mysql for more details on this modifier in the DBD interface.
    With "mysql_use_result", as opposed to "mysql_store_result", the server won't send any record to the client until you use a "fetch" method. What happens with the default mode is that the server sends all the records at once, and the "fetch" method is just browsing a local copy of the data.
 _  _ _  _  
(_|| | |(_|><

In reply to Re: DBI/mysql gathering all rows on execute by gmax
in thread DBI/mysql gathering all rows on execute by sgifford

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • 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 surveying the Monastery: (3)
    As of 2020-02-20 02:04 GMT
    Find Nodes?
      Voting Booth?
      What numbers are you going to focus on primarily in 2020?

      Results (86 votes). Check out past polls.