用于排序:如何建立索引
product表:
========================================================================
id(主键)
title(varchar)
cid(产品分类)
userid(用户id)
updatetime(更新时间)
========================================================================
现在希望能够按分类查看产品,同时产品按更新时间排序,那么两种索引方式:
1、建立cid索引,并建立updatetime索引,用这个语句查询:
(1)select * from product where cid=123 order by updatetime desc
2、建立复合索引cid+updatetime,这样查询:
(2)select * from product where cid=123 order by updatetime desc
(3)select * from product where cid=123 order by cid,updatetime desc
哪种方式正确?或者都不正确?