排列条件限制语句时候,应该把确定性的条件排前边
select count(1) from {tablename} where source='{STRING0}' and ua ~ '{STRING1}';
select count(1) from {tablename} where ua ~ '{STRING1}' and source='{STRING0}';
上面两条查询语句相比,第一条的效率要高些。
原理:查询语句的条件会串行执行,即按第一个条件得到的结果集作为第二个条件的执行集。