The trouble is that it is only "by happenstance" that you can obtain the 
count() after a single step.  There may be cases where you cannot, or where the 
rows are ordered by subsorted blocks, or by other mythical magical creatures 
that return some "random" number of computer results per step.

Executing a query returns one row for each step.  How many rows are availalbe 
"in the background" in one call to step is a detail of magic upon which you 
cannot rely.


---
The fact that there's a Highway to Hell but only a Stairway to Heaven says a 
lot about anticipated traffic volume.

>-----Original Message-----
>From: sqlite-users [mailto:sqlite-users-
>boun...@mailinglists.sqlite.org] On Behalf Of x
>Sent: Friday, 19 January, 2018 08:50
>To: SQLite mailing list
>Subject: Re: [sqlite] [EXTERNAL] get stmt row count
>
>Keith & Simon, are you not both missing the point? I want the rows
>and the count but without having to run two queries.
>
>I tried the following (let stmt1 represent the original query and
>stmt2 the count(*) version of that query).
>
>stmt1 took 6+ secs for the first step.
>stmt2 took 6+ secs to get the count.
>
>Counting using
>
>int Count=1;
>while (sqlite3_step(stmt1)) Count++;
>
>after the first step took under 2 secs BUT in order to then get the
>rows I’d have to reset stmt1 which would result in the pre-first step
>code being run again at the first step call (another 6+ secs down the
>drain).
>
>I’m thinking (but I’m by no means sure) that sqlite’s pre-first step
>code should be able to calculate the row count as it went along at
>virtually no cost. I realise it would only be a solution for queries
>sorted by non-indexed columns (i.e. where sqlite’s pre-first step
>code had to consider all result set rows).
>
>
>
>
>
>_______________________________________________
>sqlite-users mailing list
>sqlite-users@mailinglists.sqlite.org
>http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users



_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to