In the following code I try select by group on one column.  I am
assuming the query optimizer will figure to stop gathering column 1s
right away because there are no other selection constraints.  Yet in
the example, sql still looks through the entire table for additional
column ones as one can see by looking as the column key it produces,
the column key at the end of my group in column1.


C:\R\SQLite>sqlite3
SQLite version 3.6.23.1
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
sqlite> drop table T0;
Error: no such table: T0
sqlite> create table  T0(
   ...> c1 INTEGER PRIMARY KEY autoincrement,
   ...> c2 text);
sqlite>
sqlite>
sqlite> insert into T0 (c2) values ('a');
sqlite> insert into T0 (c2) values ('a');
sqlite> insert into T0 (c2) values ('a');
sqlite> insert into T0 (c2) values ('b');
sqlite> insert into T0 (c2) values ('b');
sqlite> insert into T0 (c2) values ('c');
sqlite> insert into T0 (c2) values ('a');
sqlite> insert into T0 (c2) values ('d');
sqlite>
sqlite> select 'Start';select * from T0;
Start
1|a
2|a
3|a
4|b
5|b
6|c
7|a
8|d
sqlite> select 'Start';select * from T0 group by c2;
Start
7|a
5|b
6|c
8|d
sqlite>


In other words, is group by searching rows unnecessarily.  I did not
ask for the last one in the group?
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to