在数据库技术中,Aggregation function又称之为set function,其含义为输入为一个set,输出为聚合结果。具体包括:
COUNT()
AVE()
MN()
MAX()
SUM()
Aggregation function有两种用法,一种单独使用,另一种是和GROUP联合使用。我们先讨论单独使用的情形。
当单独使用的时候,其输出只有一条结果。在MySQL的源码中,涉及到两个位置标记QUERY是否使用了aggregation function,这两个位置都位于st_select_lex类中(sql_lex.h):
class st_select_lex {
/**
@return true if this query block is implicitly grouped and returns exactly
one row, which happens when it does not have a HAVING clause.
*/
bool is_single_grouped() const
{
return m_agg_func_used &&
group_list.elements == 0 &&
m_having_cond == NULL;
}
bool m_agg_func_used; //
/**
True if contains or aggregates set functions.
@note this is wrong when a locally found set function is aggregated
in an outer query block.
*/
bool with_sum_func;
}</

本文探讨了数据库技术中的聚合函数,如COUNT(), AVG(), MIN(), MAX(), SUM()等。详细分析了它们在MySQL中单独使用时的特性,指出在MySQL源码中,通过st_select_lex类的m_agg_func_used和with_sum_func标志来判断查询是否使用了聚合函数,这两个标志可能因不同开发者引入而存在冗余。"
137568600,163349,架构师的生存之道:目标与能力,"['系统架构', '架构设计']
&spm=1001.2101.3001.5002&articleId=77692843&d=1&t=3&u=bc3f439dd4104230946d7ac118276b72)
3万+

被折叠的 条评论
为什么被折叠?



