SQL 查询优化:创建联合索引提升效率
根据以下 SQL 语句,可以考虑创建以下联合索引:
(category_id, start_time, end_time, status, is_need_quota, num, sell_num, deleted_at, weight, price)
其中,'category_id' 是过滤条件中的第一个字段,可以帮助优化查询效率;'start_time' 和 'end_time' 是时间范围过滤条件,可以一起构建索引;'status'、'is_need_quota'、'num'、'sell_num'、'deleted_at' 是其他过滤条件,也可以一起构建索引;最后,'weight' 和 'price' 是排序条件,也可以一起构建索引。
原文地址: https://www.cveoy.top/t/topic/mLi3 著作权归作者所有。请勿转载和采集!