Re: [sqlite] ORDER BY DESC after GROUP BY not using INDEX - intentionally?

2013-10-21 Thread Fabian Büttner
Thanks. I think using GROUP BY without aggregates is a strange way to remove duplicates, anyway. Not intentional. SQLite simply fails to recognize that by using the GROUP BY in descending order it could avoid the ORDER BY clause. This is an optimization that we have never considered because it

[sqlite] ORDER BY DESC after GROUP BY not using INDEX - intentionally?

2013-10-21 Thread Fabian Büttner
Hi, I have been thinking about a question on stackoverflow (http://stackoverflow.com/questions/19236363/select-distinct-faster-than-group-by), where some SQL framework removes duplicates from results using GROUP BY instead of DISTINCT. I don't want to discuss that this might not be a good

Re: [sqlite] SQLite keeps on searching endlessly

2013-10-19 Thread Fabian Büttner
I cannot definitely solve your problem but I can think of some things to try. First, do these: ANALYZE; CREATE INDEX map_dsn ON map (d, s, n); CREATE INDEX map_dns ON map (d, n, s); then execute the same SELECT. Does it have the same problem ? Does the EXPLAIN QUERY PLAN tell you which

Re: [sqlite] SQLite keeps on searching endlessly

2013-10-19 Thread Fabian Büttner
You may want to put the columns with the highest selectivity first in your index. The device 15 has nearly 10 entries in the table while the remaining of the 600 Million records belong to another device. E.g., CREATE INDEX map_index ON map (d, ...); Also, you should run ANALYZE map so that