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
2.Index会加快query速度,但是会减慢insert速度。若要插入几十万笔资料,可以先delete index,然后再insert,再把index加上去
3.Insert 资料时,如果运算少,应用insert into [table1] (select * from [table2])。
4.如果两个data base间倒资料,应用dblink。如果速度慢,可以先create temporary table, 再用dblink
5.如果删除一个table中的所有资料,要用tuncate,不要用delete from table
本文提供了SQL查询优化的方法,包括避免在查询中对字段进行运算、利用索引提高查询速度但注意其对插入操作的影响、通过直接插入减少计算量、使用dblink在不同数据库间高效转移数据及如何快速清空表中的所有记录。
1892

被折叠的 条评论
为什么被折叠?



