如果表中有10W条数据,其中一个字段是AGE
我想查AGE19的,SQL写成这样
select age from table where age19
感觉这样会很慢,有什么方法能缩短查询时间呢?
我想到一个办法,就是先取出表中一部分数据,放到临时表里,从临时表里查,然后删除临时表,然后再取另外一部分数据,如此循环,不知道是否可行。
select age from table where age19
=>
select age from table where age>19 or age
select age from table where age>19
union all
select age from table where age<19
(age上有建立索引)