Hi,
If there is an index on this column, then it should be used. I can't
reproduce the problem. Using 'count(HDR_EVENT_NUMBER)' is a very good
idea by the way, in theory H2 could do that automatically. What
version of H2 do you use? (For older versions, you may need to run
'analyze' manually.) Could you run "script nodata" and post the
result? My test case is:
drop table test;
create table test(id int primary key, name varchar(255));
create index idx_name on test(name);
insert into test select x, x/10000 from system_range(1, 1000000);
explain analyze select name, count(name) from test group by name;
explain analyze select name, count(id) from test group by name;
SELECT
NAME,
COUNT(NAME)
FROM PUBLIC.TEST
/* PUBLIC.IDX_NAME */
/* scanCount: 1000001 */
GROUP BY NAME
/* group sorted */
/*
total: 6720
TEST.IDX_NAME read: 6720 (100%)
*/
Regards,
Thomas
--
You received this message because you are subscribed to the Google Groups "H2
Database" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/h2-database?hl=en.