|previous : next|
This is experimental functionality, and as such subject to change. Use at your own risk!
Applies to ✅ Open Source Edition ✅ Express Edition ✅ Professional Edition ✅ Enterprise Edition
The COUNT(expression) aggregate function counts the number of non-
expression evaluations in the group. If the
expression is a constant, then there are only two options:
- The constant is
NULL, in case of which the
COUNT(NULL)value is always
0(but that's not an aggregate function, so we're currently not replacing it yet)
- The constant is anything else, in case of which the
COUNT(const)value is always
For clarity reasons, and in some RDBMS also for (slight) performance reasons,
COUNT(*) should be preferred.
Using Settings.transformPatternsCountConstant, the following transformations can be achieved:
-- With Settings.transformPatternsCountConstant active, this: SELECT COUNT(NULL), COUNT(1); -- ... is transformed into the equivalent expression: SELECT COUNT(NULL), -- Might be replaced by 0 in the future, if other aggregates are present COUNT(*);
Do you have any feedback about this page? We'd love to hear it!