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

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
The "list of massive results" is stored locally in the driver, and is fetched through whatever method you prefer. This means that if you have a large table, you will need a large buffer. This bit me too, in DBI + 'SELECT *' - Memory Use Galore?. The two solutions were as follows:

  1. Use the 'LIMIT ?,?' parameter to incrementally retrieve the information in blocks that are a managable size. For example, 'LIMIT 10,0', then 'LIMIT 10,10', etc. There is a risk, though, of duplicated or missing results if the table is modified between fetches.
  2. Use the low-level MySQL 'mysql_use_result' feature, and a separate DBI handle, which switches to a non-buffered method. There is no real risk of duplicate or missing results.
It would seem that if you are fetching the data row-by-row that the client would do the same, but this is not the case. Every time you call "execute", either explicitly or implicitly, such as through "do", the result of that is buffered in the client. This can consume an awful lot of memory, especially on tables with lots of rows.

You can reduce memory usage by selecting only a few key columns. 'SELECT *' will download everything, and if you have several long text fields, this can be very expensive. 'SELECT some_key_field', by comparision, is much more compact.

In reply to Re: Memory usage with DBI by tadman
in thread Memory usage with DBI by Kozz

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

  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?

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

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (7)
As of 2023-11-28 22:59 GMT
Find Nodes?
    Voting Booth?

    No recent polls found