SQL1
select a.* from user2 b,user1 a where b.id=? and b.id=1000000+a.id ;
SQL2
select count(*) from test t where t.phone_no like '1380755%';SQL3
select id,type from log where time >= to_date('20100110','yyyymmdd') and time < to_date('20100110','yyyymmdd')+11.数据量大时,尽量别对你查询里用到的条件列做运算,如上面的 substr,to_char
2.多表关联时,条件写在前,关联写在后。如SQL1平时工作只涉及到语句,不涉及管理 ,语句手工写 工具 pl/sql .
select a.* from user2 b,user1 a where b.id=? and b.id=1000000+a.id ;
SQL2
select count(*) from test t where t.phone_no like '1380755%';SQL3
select id,type from log where time >= to_date('20100110','yyyymmdd') and time < to_date('20100110','yyyymmdd')+11.数据量大时,尽量别对你查询里用到的条件列做运算,如上面的 substr,to_char
2.多表关联时,条件写在前,关联写在后。如SQL1平时工作只涉及到语句,不涉及管理 ,语句手工写 工具 pl/sql .
比如10000+a.id将导致a.id上的索引不可用;
同样substr(t.phone_no,1,7) = '1380755'将导致phone上的索引不可用
to_char(time,'yyyymmdd')= '20100110'会让time字段失效。另,一楼兄弟的优化方法好使。