On Thu, Jun 26, 2008 at 03:55:16PM +0200, Rapha?l KINDT scratched on the wall: > Hello, > > This two requests are differents from both compute time and results! Why? > > SELECT count(*) FROM events; -- very long for big DB > SELECT max(rowid) FROM events; -- very quick
"count(*)" counts the number of rows. "max(rowid)" returns the largest value in rowid column. "count(*)" is slow(er) because it has to walk the whole index, counting the number of items in the index. "max(rowid)" is fast because it can jump to the end of the primary-key index and just return the last value. -j -- Jay A. Kreibich < J A Y @ K R E I B I.C H > "'People who live in bamboo houses should not throw pandas.' Jesus said that." - "The Ninja", www.AskANinja.com, "Special Delivery 10: Pop!Tech 2006" _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users