mysql建立索引
supe_spaceitems表
组合索引有3个,uid、catid、type
其中,uid会用到类似于:
【1】where uid=
【2】where uid= and type=
【3】where uid= and type= and folder=
【4】where uid= and type= and folder= and top=
【5】where uid= and type= and folder= and top= and dateline=
才需要建立
catid的组合索引,有类似于:
【1】where catid=
【2】where catid= and folder=
【3】where catid= and folder= and dateline=
才需要建立
type的组合索引,有类似于:
【1】where type=
【2】where type= and folder=
才需要建立
其它单个索引,最好是需要关联表的时候才建立,比如:
dev_tag_spaceitems.itemid = supe_spaceitems.itemid
那么这个时候,才需要将supe_spaceitems.itemid建立索引
比如:folder=1或者m2=1,最好都不要建立索引
———————————-
索引会提高查询速度,但是同时update、insert、delete都会重新更新索引文件一次
组合索引会导致mysql磁盘文件膨胀很厉害,比如:你建立的3个组合索引:uid、catid、type
近期评论