What does EXPLAIN QUERY PLAN says?
Il giorno 13 aprile 2012 21:04, Marc L. Allen <[email protected]>ha scritto: > Maybe the query analyzer isn't smart enough to do two seeks in this case, > so it does a scan? > > > -----Original Message----- > > From: [email protected] [mailto:sqlite-users- > > [email protected]] On Behalf Of Steinar Midtskogen > > Sent: Friday, April 13, 2012 3:00 PM > > To: [email protected] > > Subject: [sqlite] Why are two select statements 2000 times faster than > > one? > > > > Hello, > > > > I have a table with "unix_time" as primary key and I want to get the > > minimum and maximum values of "unix_time". When I do: > > > > SELECT min(unix_time), max(unix_time) from table; > > > > it is very slow. It takes about 250ms, nearly everything in the > > step() call. > > > > However, if I do: > > > > SELECT min(unix_time) FROM table; SELECT max(unix_time) FROM table; > > > > to get the same values, it takes a fraction of the time. The speedup > > is more than 2000x. > > > > Why? > > > > -- > > Steinar > > _______________________________________________ > > sqlite-users mailing list > > [email protected] > > http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users > _______________________________________________ > sqlite-users mailing list > [email protected] > http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users > _______________________________________________ sqlite-users mailing list [email protected] http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

