List:General Discussion« Previous MessageNext Message »
From:Ken Gieselman Date:September 18 2005 7:53pm
Subject:Re: Result row count *without* buffering all results?
View as plain text  
Scott Gifford wrote:
> Ken Gieselman <ken@stripped> writes:
> 
> [...]
> 
> 
>>So, here's my question: How can I find out how many rows are being
>>returned by a query, without using mysql_stmt_store_result() to
>>buffer all the rows back to the client?
> 
> 
> One straightforward way is to replace the SELECT clause with just
> SELECT COUNT(*) and execute that query first.
> 
> -----ScottG.
> 

Yeah, that's my "fall-back" option -- though the thought of executing the query 
twice is a bit daunting.  Some of the tables run into billions of rows per year 
(the merge tables anyhow, the data tables are broken down by month to keep them 
from becoming totally unmanageable), and a multi-year search can take a while to 
grind out.

Seems to me that by the time the first query execution is done, the server 
should *know* exactly how many rows are in the result set -- just need to find 
the magic trick that allows the client to query that number, rather than 
counting for itself as it buffers them.

Thanks!
ken
-- 
===========================================================================
               "Diplomacy is the weapon of the Civilized Warrior"
                                     - Hun, A.T.

Ken Gieselman                                           ken@stripped
Endlessknot Communications                       http://www.endlessknot.com
===========================================================================
Thread
Result row count *without* buffering all results?Ken Gieselman18 Sep
  • Re: Result row count *without* buffering all results?Scott Gifford18 Sep
    • Re: Result row count *without* buffering all results?Ken Gieselman18 Sep
      • Re: Result row count *without* buffering all results?Scott Gifford19 Sep
      • Re: Result row count *without* buffering all results?Harrison Fisk19 Sep
        • Re: Result row count *without* buffering all results?Ken Gieselman19 Sep