SQL performance

来源:互联网 发布:小学生学英语软件 编辑:程序博客网 时间:2024/06/05 11:12

1  不要让field参与运算

SELECT cr_id,log_when as last_modify_date FROM changelog WHERE log_when >to_date('20090527','YYYYMMDD HH24:MI:SS')-1/3

         <1 secs

       SELECT cr_id,log_when as last_modify_date FROM changelog WHERE log_when+1/3 >to_date('20090527','YYYYMMDD HH24:MI:SS')

         >90 secs

2Index会加快query速度,但是会减慢insert速度。若要插入几十万笔资料,可以先delete index,然后再insert,再把index加上去

3Insert 资料时,如果运算少,应用insert into [table1] (select * from [table2])

4.如果两个data base间倒资料,应用dblink。如果速度慢,可以先create temporary table, 再用dblink

5.如果删除一个table中的所有资料,要用tuncate,不要用delete from table

原创粉丝点击