Glancing through the cheetah book, there's three ways to get data from DBI: row methods (each time you call the method, it returns the next row), atomic methods (for returning only one row, doesn't help you), and batch methods (fetchall_arrayref(), selectall_arrayref(), like chromatic mentioned). The batch methods can indeed knock a system on its behind if the result set is big; it's certainly better to prepare and execute your SELECT, roughly make sure you can handle the results, then use fetchall_arrayref rather than selectall_arrayref. If you don't use all the data, though, this can be wasteful. If you're grabbing sequential sections of the result set (which it looked like from your question), I don't see a problem with just doing atomic fetches 20 times a pop when you need the next set.
If you're using MySQL (I haven't used any other rdbms), LIMIT is a good option, like others have said. From the manual: "mysql> select * from table LIMIT 5,10; # Retrieve rows 6-15" looks like what you need. But unless the offset parameter of LIMIT can be a bound value (anyone know?), I think you'd take a performance hit for having the DB redo the query plan each time.
A side note that bit me: if you want to use LIMIT with UPDATE, you'll need MySQL 3.23.
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, details, 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, summary, 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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.