It's not clear from your question whether or not you need the total number of rows the query might have returned.
If you need the first 100 rows from a query that could return several orders of magnitude more rows, do the fetchrow 100 times and then ->finish the statement to tell the server it can pitch the remainder.
If you also need the total number of rows the query would have returned, do that as a separate step using count().
If your original query would have returned only 101 rows, you don't save, but you don't get hammered the way you would if you went ahead and fetched all 10,000 rows even if you only needed 100.
If you are doing two different things, you probably want two separate queries. If performance becomes an issue, you can optimize each separately, with the different aims not getting in the way of each other.
In reply to Re: fetch row or fetchall
by herveus
in thread fetch row or fetchall
by hakkr
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |