On Thu, 25 Apr 2013 10:29:34 +0200 Hick Gunter <h...@scigames.at> wrote:
> AFAIK SQLite treats GROUP BY the same way as ORDER BY (taken from > hints in the virtual table description). That might be so, in some limited sense. It's obviously false in general because they mean different things and have different effects. > If you have an index that covers the GROUP BY clause in field order, > then aggregate functions need store only the current value; if not, > then you need an ephemeral table to hold the aggregate values. Nonsense. The query parser sees GROUP BY A,B. The optimizer sees an index ordered B,A. By permuting the order of the columns in the GROUP BY clause, it finds a match for the index and uses it. Yes, the problem is O(n^2), where n is the number of columns in the GROUP BY, but n is always small; even 7 columns could be checked in less than 50 iterations. --jkl _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users