On Thu, 11 Dec 2014 15:19:26 +0000 Simon Slavin <slav...@bigfraud.org> wrote:
> In my table which had about 300 million (sic.) rows I did this > > SELECT count(*) FROM myTable; > > to count the number of rows. After half an hour it was still > processing and I had to kill it. > > I know that the internal structure of a table means that this number > isn't simple to produce. But is there really no faster way ? This > table is going to have about six times that amount soon. I really > can't count the rows in less than a few hours ? Try SELECT count(myTable.indexed_column) FROM myTable; indexed_column is a column of your table that is the leftmost NOTNULL column in a index, for example the rowid. count(*) will look at every row in the table pages. The count(myTable.indexed_column) with the restrictions I said, should use the index, which (again) should use a lot less pages, minimizing the I/O. > Simon. --- --- Eduardo Morras <emorr...@yahoo.es> _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users