SQL改寫優化
update /*+ gather_plan_statistics */ wxh_tbd a
set (object_id, object_name) = (select object_id, object_name
from wxh_tbd b
where a.object_id = b.object_id);
set (object_id, object_name) = (select object_id, object_name
from wxh_tbd b
where a.object_id = b.object_id);
試了N種辦法,都走不上HASH。
改寫如下:
update (
select /*+ BYPASS_UJVC use_hash(a b) ordered */ a.object_name,a.object_id,b.object_name new_object_name,b.object_id new_object_id
from wxh_tbd a, wxh_tbd b
where a.object_id=b.object_id
) set object_name=new_object_name,object_id=new_object_id
;
select /*+ BYPASS_UJVC use_hash(a b) ordered */ a.object_name,a.object_id,b.object_name new_object_name,b.object_id new_object_id
from wxh_tbd a, wxh_tbd b
where a.object_id=b.object_id
) set object_name=new_object_name,object_id=new_object_id
;
如果OBJECT_ID是唯一索引,就不用加BYPASS_UJVC 了
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/22034023/viewspace-722640/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- MySQL效能優化之簡單sql改寫MySql優化
- sql改寫優化:簡單規則重組實現SQL優化
- 小米開源自研智慧SQL優化與改寫工具SOAR使用指南SQL優化
- DB2 SQL改寫DB2SQL
- Oracle case when改寫SQLOracleSQL
- MySQL的SQL等價改寫MySql
- SQL改寫的方法,select group by sumSQL
- sql優化之邏輯優化SQL優化
- 資料庫優化 - SQL優化資料庫優化SQL
- SQL SERVER優化SQLServer優化
- SQL優化指南SQL優化
- 一種提升SQL改寫效率的方法SQL
- SQL 改寫系列七:謂詞移動SQL
- SQL 改寫系列六:謂詞推導SQL
- Oracle效能優化-SQL優化(案例一)Oracle優化SQL
- Oracle效能優化-SQL優化(案例二)Oracle優化SQL
- Oracle效能優化-SQL優化(案例三)Oracle優化SQL
- Oracle效能優化-SQL優化(案例四)Oracle優化SQL
- SQL優化參考SQL優化
- sql優化專題SQL優化
- SQL語句優化SQL優化
- SQL效能優化技巧SQL優化
- MySQL-SQL優化MySql優化
- 慢Sql優化思路SQL優化
- Oracle SQL優化之sql tuning advisorOracleSQL優化
- SQL優化案例-使用with as優化Subquery Unnesting(七)SQL優化
- SQL Server最佳化標量函式改寫內聯表值函式SQLServer函式
- SQL KEEP 視窗函式等價改寫案例SQL函式
- PostgreSQL優化案例之 反連線與外連線等價改寫SQL優化
- 資料庫優化SQL資料庫優化SQL
- MYSQL SQL語句優化MySql優化
- SQL優化之limit 1SQL優化MIT
- 優化sql查詢速度優化SQL
- (轉)SQL 優化原則SQL優化
- SQL優化的方法論SQL優化
- 史上最全SQL優化方案SQL優化
- MySQL SQL優化案例(一)MySql優化
- MySQL之SQL優化技巧MySql優化
- [20201224]sql優化困惑.txtSQL優化