What does EXPLAIN QUERY PLAN says?
Il giorno 13 aprile 2012 21:04, Marc L. Allen <mlal...@outsitenetworks.com>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: sqlite-users-boun...@sqlite.org [mailto:sqlite-users- > > boun...@sqlite.org] On Behalf Of Steinar Midtskogen > > Sent: Friday, April 13, 2012 3:00 PM > > To: sqlite-users@sqlite.org > > 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 > > 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 > _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users