假设我有一个表persons
:
CREATE TABLE persons
(
id INTEGER,
age INTEGER,
PRIMARY KEY (id)
);
以下两个查询之间有什么区别吗?
查询#1:
SELECT age, count(*)
FROM persons
GROUP BY age
ORDER BY count(*);
查询#2:
SELECT age, count(*) AS cnt
FROM persons
GROUP BY age
ORDER BY cnt;
第一个查询实际上会count()
两次,还是会被查询规划器优化掉?它取决于供应商还是由标准定义?