这么多查询条件如何建立索引?
gszxt 2010-09-03 02:42:14 product表结构大概如下:
productid(int主键),shopid(int),title(varchar),icon(varchar),price(float),status(tinyint),isIndex(tinyint),updateisIndex(datetime)categoryid(int),sortid(int),brandid(int),clickCnt(int),siteIstop(tinyint),isnews(tinyint),istop(tinyint)
正面是网站中用到的一些查询:
select top 4 shopid,productid,title,icon,price from product where status=1 and isIndex=1 order by clickCnt desc
select top 5 productid,title,price,icon from product where status=1 and shopid=1111
select top 222 * from product where userid=2323
select top 2 * from product where status=1 and isIndex=1 order by updateisIndex desc
select top 12 * from product where status=1 and siteIstop=1
select count(productid) as cnt from product where shopid=2332 and istop=1
select top 4 shopid,productid,title,price,icon from product where status=1 and isnews=2 order by productid desc
select top 10 shopid,productid,title,icon,price from product where status=1 and siteIstop=1 order by productid desc
select top 12 shopid,productid,title,icon from product where status=1 and categoryid=4 order by productid desc
select top 4 productid,shopid,title,price,icon from product where productid in(select max(productid) from product where istop=1 and status=1 group by shopid) order by productid desc
select top 4 shopid,productid,title,icon,price,clickCnt from product where status=1 order by clickCnt desc,productid desc
select top 4 shopid,productid,title,icon,price from product where status=1 and istop=1 order by productid desc
select count(shopid) as num from product where status=1 and brandid=20
select count(brandid) as num from product where status=1 and categoryid=20
select top 8 * from product where istop=1 and shopid=20 and status=1 order by productid desc
select top 2 * from product where status=1 and istop=1 and shopid=222 order by productid desc
这样的应用表中应该如何建索引好呢?