对数据库的字段建立索引,会加快很多,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=20order by最好用聚合索引