我在更新的时候使用了如下语句,需要更新的数据(t1表)大约在30万左右,用于查询的表t2数据量在4万左右,这条语句执行起来相当的慢,请问有没有什么好方法可以提高执行的效率呢?update t1 set area=(
select area from t2
where substr(t1.number,1,3)=t2.number
)
where exists (
select area from t2
where substr(t1.number,1,3)=t2.number
)
select area from t2
where substr(t1.number,1,3)=t2.number
)
where exists (
select area from t2
where substr(t1.number,1,3)=t2.number
)
解决方案 »
- 为什么我用pl/sql中创建的oracle存储过程都是VALID的 都不能使用
- SQL语句优化问题 合并两个 select 语句并显示结果
- 关于ORACLE序列连续性的问题请教下
- Formbuilder fmx文件显示问题
- 新手提问:又是一个查询问题,我思路又不对,恳请请各位指点。
- 请介绍关于linux下安装Oracle的资料
- 如何建新數據庫?
- ?????怪事情,高手肯定要帮忙的哦!!!??????
- 各位ORACLE前辈请指点很菜的一个问题 在线求救 有分100分 急!!!!!!1
- 小小问题,
- 为啥select * from dual connect by rownum < 151;最多只有100条记录?
- 为什么直接查询视图同将视图中SQL语句拿出来查询得到的结果不一样?
create index ix_t1_substr_num on t1 (substr(number,1,3);
对t2创建索引:
create index ix_t2_num on t2 (number);
建完索引后最好用
analyze table t1 estimate statistics;
analyze table t2 estimate statistics;
对两个表都做统计分析,以便oracle 能以最优方式执行查询
select area from t2
where substr(t1.number,1,3)=t2.number
)
where substr(t1.number,1,3) in (select t2.number from t2)
这样写不知道行不行
另外在ORACLE的管理平台选中你用到的表和视图,点右键执行分析试一下
set area=t2.area
from t1 join t2 on substr(t1.number,1,3)=t2.number
这样就好了吧lz
select area from t2
where t1.number like t2.number||'%'
)
where exists (
select 1 from t2 where t1.number like t2.number||'%')建立函数索引的话比较影响插入数据的速度
且不好维护,插入数据的时候,需要执行函数,按结果更新索引
能不用函数就尽量不要用函数索引
set area=t2.area
from t1 join t2 on substr(t1.number,1,3)=t2.number他会告诉我语句未正确结束!