oracle数据库 怎样建索引 让以下sql跑到最快????大神救我。。。。
update tradedetail t set
t.finareacode=(select max(t1.finareacode) from up_areacode t1 where t.taxid=t1.taxid or t.taxname=t1.taxname)
where exists (select t1.finareacode from up_areacode t1 where t.taxid=t1.taxid or t.taxname=t1.taxname);
补充:我的 版本为 oralce 10g ,请问 朋友 怎样在 tradedetail 和 up_areacode 表中建索引?????
追问:请问朋友 那么怎样建两张表中的索引呢,是建where后面的条件字段吗???麻烦了朋友请问:表中的数据量很大的话 使用函数 or 会使sql语句的效率下降吗,或者 taxid纯正空null 或 taxname 纯在 null 的情况 ?????如果加上 is not null 能够提高 语句的效率吗?????有时间请帮我解释下,我相信你的解释 ,理论上行得通。。。 你有索引方面的文档吗??有的话能否传个给我看看。。。。感谢您回答!!!!!O(∩_∩)O谢谢
答案:不知道你的数据库版本是什么。 看oracle 的执行计划。自己分析一下。
10以上可以通过awr看oracle的建议。
再一点exists 后面的select t1.finareacode 可以改成select 1,可以提高一点效率。 如下:update tradedetail t set
t.finareacode=(select max(t1.finareacode) from up_areacode t1 where t.taxid=t1.taxid or t.taxname=t1.taxname)
where exists (select 1 from up_areacode t1 where t.taxid=t1.taxid or t.taxname=t1.taxname);
上一个:oracle 数据库中的as 表示什么意思?
下一个:oracle 10g R2数据库,用pl/sql developer 删除数据时,执行DELETE FROM TABLE1后就一直停在执行的状态,