Derby transforms COUNT(nonNullableColumn) into COUNT(*). This improves performance by potentially reducing the number of referenced columns in the table (each referenced column needs to be read in for each row) and by giving the optimizer more access path choices. For example, the cheapest access path for
SELECT COUNT(*) FROM t1
is the index on t1 with the smallest number of leaf pages, and the optimizer is free to choose that path.
Table of Contents