count()
- 使用汇总表
- 外部缓存
关联优化
- on 列上有索引
- group by/order by只是涉及一个表的列
分页优化
或者使用between and 替代已知范围/先缓存大量的数据
union
创建并填充临时表执行union查询
- 最好使用union all除非要消除重复行,临时表有distinct临时表数据唯一性检查,代价非常高。
- union 区分冷热数据
或者使用between and 替代已知范围/先缓存大量的数据
创建并填充临时表执行union查询