Igor I disagree, but please feel free to correct me if I'm wrong. Consider the 
following sql statement:

select * from table1 order by last_name;

Sqlite must first order the data since an order by clause is specified. 
(assuming there is no index to utilize). The data must be fetch, sorted and 
stored in a temporary file or in memory.

But without the order by then sqlite does not need to fetch the data prior to 
select. 

So only sometimes does it fetch all data at the first step.

Ken

--- On Wed, 11/5/08, Igor Tandetnik <[EMAIL PROTECTED]> wrote:

> From: Igor Tandetnik <[EMAIL PROTECTED]>
> Subject: Re: [sqlite] row count after a select
> To: sqlite-users@sqlite.org
> Date: Wednesday, November 5, 2008, 7:38 AM
> <[EMAIL PROTECTED]> wrote in message
> news:[EMAIL PROTECTED]
> > Do you know a way to count the number of rows
> identified by a select
> > statement, just after the first call to sqlite3_step ?
> Of course
> > without fetching the entire result set, nor having to
> systematically
> > add count(*)
> 
> You seem to believe SQLite retrieves the whole resultset on
> the first 
> sqlite3_step call. This is not the case. SQLite produces
> records one by 
> one, on request, every time you call sqlite3_step. It
> simply doesn't 
> know how many there are going to be, until on some
> sqlite3_step call it 
> discovers there are no more.
> 
> Igor Tandetnik 
> 
> 
> 
> _______________________________________________
> sqlite-users mailing list
> sqlite-users@sqlite.org
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to