That doesn't work for me: I am trying to avoid (select col1, col2, ... colx ) from ...
and want just a row count which is much less resource intensive. I have users who need to execute queries that generate a large number of rows, I have other users that create queries that generate a large number of rows by accident (i.e. cross joins). I have no control over what they enter but I want to do something to warn them that their query might result in an over large number of rows and a limit clause might be a solution. if however they have already applied a limit clause there is no need for a warning. Before I am asked - for some of my users huge data sets might be OK as they can use my application to massage the data before creating a report or exporting the results set. parsing the query and identifying the limit clause is an option, but I hope there might be a simpler way. Paul www.sandersonforensics.com skype: r3scue193 twitter: @sandersonforens Tel +44 (0)1326 572786 http://sandersonforensics.com/forum/content.php?195-SQLite-Forensic-Toolkit -Forensic Toolkit for SQLite email from a work address for a fully functional demo licence On 5 March 2016 at 13:05, Clemens Ladisch <clemens at ladisch.de> wrote: > Paul Sanderson wrote: >> I am trying to determine before a query is executed how many rows will >> be returned. the following query works as expected >> >> select count(*) from table >> >> but >> >> select count(*) from table limit 100 >> >> still returns the number of rows in the table not the number of rows >> that would be returned by the query. > > "The query" is the one that has the "limit" clause. What else should > the database execute? > > As documented <http://www.sqlite.org/lang_select.html>, the result rows > are generated before the LIMIT clause is applied. > > To determine how many rows would be returned by an arbitrary query, use: > > SELECT COUNT(*) FROM (SELECT ...); > > > But why do you want to determine the number of rows in the first place? > > > Regards, > Clemens > _______________________________________________ > sqlite-users mailing list > sqlite-users at mailinglists.sqlite.org > http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users