对于sql语句or优化的一些见解

若是数据库有100万条数据,例如使用 select  *from   table   id=1 or id=2   查询会扫描所有数据速度效率表较慢, 若是用union和索引能够大大优化查询速度效率,上面语句改为数据库 select *from table id=1 union select *from table id=2   若是id上有索引只会扫描id=1和id=2的数据,扫描100万条数据
相关文章
相关标签/搜索