mysql数据库加快搜索速度

来源:互联网 发布:淘宝全屏店招在线制作 编辑:程序博客网 时间:2024/06/05 17:03

对数据库的字段建立索引,会加快很多,100万条数据大概只需要四秒

create index iname on tb (age)

建立索引的语句如上所示

iname是索引的名字 tb是表名  age是字段名

原来需要的时间特别长

索引不能够添加在text类型的字段上

不要使用or,or用的是全局搜索而不是索引,使用union,用的是索引

select id from t where num=10 union  select id from t where num=20 
order by最好用聚合索引

0 0
原创粉丝点击