一個SQL優化
把where條件改寫了
改用case when
-
(
- (
- (
- (select aco.iauthcontrol
- from BG_AUTHCONTROLOBJ aco
- where aco.cobjcode = \'105\' and
- aco.corgnid = {CORGNID:\'\'}) = 0
-
)
-
or
- (select count(cguid)
- from BG_AUTHCONTROLOBJ aco
- where aco.cobjcode = \'105\' and
- aco.corgnid = {CORGNID:\'\'}) = 0
- )
-
or
- (
- (select aco.iauthcontrol
- from BG_AUTHCONTROLOBJ aco
- where aco.cobjcode = \'105\' and
-
aco.corgnid = {CORGNID:\'\'}) = 1 and
- (
- (
- (select akj.iauthcontrol
- from BG_AUTHASSIGNKJ akj
- where akj.carchiveguid ={cBGCaliberKey3GUID:\'\'} and
-
akj.corganguid = {CORGNID:\'\'}) = 0
-
or
- (select count(cguid)
- from BG_AUTHASSIGNKJ akj
- where akj.carchiveguid ={cBGCaliberKey3GUID:\'\'} and
- akj.corganguid = {CORGNID:\'\'}) = 0
-
)
-
or
- (
- (select akj.iauthcontrol
- from BG_AUTHASSIGNKJ akj
- where akj.carchiveguid ={cBGCaliberKey3GUID:\'\'} and
- akj.corganguid = {CORGNID:\'\'}) = 1 and
- b1.cguid in ( select distinct babg.cbillcguid
- from BG_AUTHASSIGNBG babg
- where babg.cuserguid = {cCreatorGUID} and
- babg.corganguid = {CORGNID:\'\'} and
- babg.icontrol = 1 and
- babg.cobjguid = (select baco.cguid
-
from BG_AUTHCONTROLOBJ baco
- where baco.cobjcode = \'105\' and
-
baco.corgnid = {CORGNID:\'\'})
-
)
- )
-
)
-
)
- )
- (case (select aco.iauthcontrol
- from BG_AUTHCONTROLOBJ aco
- where aco.cobjcode = \'105\' and
-
aco.corgnid = {CORGNID:\'\'})
- when 1 then (case (select akj.iauthcontrol
- from BG_AUTHASSIGNKJ akj
- where akj.carchiveguid ={eleType:\'\'} and
-
akj.corganguid = {CORGNID:\'\'})
- when 1 then (case when c.cguid in (select distinct babg.cbillcguid
- from BG_AUTHASSIGNBG babg
- where babg.cuserguid = {cCreatorGUID} and
- babg.corganguid = {CORGNID:\'\'} and
- babg.icontrol = 1 and
-
babg.cobjguid = (select baco.cguid
-
from BG_AUTHCONTROLOBJ baco
- where baco.cobjcode = \'105\' and
- baco.corgnid = {CORGNID:\'\'}) ) then 1
-
else 0 end
-
)
-
else 1 end
-
)
-
else 1 end
- )=1
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/29437301/viewspace-1365754/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 一個sql的優化SQL優化
- 記一個SQL優化案例SQL優化
- 一個SQL語句的優化SQL優化
- SQL優化(一)SQL優化
- 一個SQL效能問題的優化探索SQL優化
- MYSQL 阿里的一個sql優化問題MySql阿里優化
- 優化同事發過來的一個sql優化SQL
- SQL優化--用各種hints優化一條SQLSQL優化
- Oracle效能優化-SQL優化(案例一)Oracle優化SQL
- 幫朋友優化個sql優化SQL
- 如何優化這個sql?優化SQL
- [轉]轉一個關於優化sql的文章優化SQL
- oracle優化一例之sql優化Oracle優化SQL
- MySQL SQL優化案例(一)MySql優化
- oracle sql like優化(一)OracleSQL優化
- 8個SQL講解優化SQL優化
- ORACLE SQL效能優化系列 (一)OracleSQL優化
- 記一次sql優化SQL優化
- PL/SQL優化一例SQL優化
- 【SQL優化】SQL優化工具SQL優化
- SQL Server優化之SQL語句優化SQLServer優化
- SQL優化SQL優化
- with as優化sql優化SQL
- 效能優化案例-SQL優化優化SQL
- MySQL幾個簡單SQL的優化MySql優化
- 【SQL Server 優化效能的幾個方面】SQLServer優化
- MySQL之SQL優化詳解(一)MySql優化
- 一條sql的優化過程SQL優化
- 一條sql語句的優化SQL優化
- SQL優化引出的問題(一)SQL優化
- 一次sql優化小記SQL優化
- 從一條問題SQL優化看SQL TransformationSQL優化ORM
- 資料庫優化 - SQL優化資料庫優化SQL
- sql優化之邏輯優化SQL優化
- SQL優化:limit分頁優化SQL優化MIT
- MySQL 效能優化之SQL優化MySql優化
- 【SQL優化】SQL優化的10點注意事項SQL優化
- SQL SERVER中SQL優化SQLServer優化