OB一哥们找我优化条SQL,反馈在OceanBase执行时间很慢需要 3184s才能出结果,安排。

原SQL:

 select M.POLICY_CHARGE_ID as policyChargeId,
M.POLICY_NO as policyNo,
M.ENDORSE_NO as endorseNo,
(select ec.entity_name
from AAAAAAAAAAA ec
where ec.parent_code = 'BA36'
and ec.AAAAAAAAAAA = M.line) as line,--1
(select o.name
from BBBBBBBBBBBB o
where o.code = M.DEPTGRP_CODE
and o.parent_id = (select z.org_id
from BBBBBBBBBBBB z
where z.code = M.BRANCH_CODE)) as deptgrpCode,
(select o.name
from BBBBBBBBBBBB o
where o.code = M.DEPT_CODE
and o.parent_id =
(select z.org_id
from BBBBBBBBBBBB z
where z.code = M.DEPTGRP_CODE
and z.parent_id =
(select i.org_id
from BBBBBBBBBBBB i
where i.code = M.BRANCH_CODE))) as deptCode,
(select e.name
from CCCCCCCC e
where e.code = M.HANDLER_CODE
and e.unit_code = M.Branch_Code) as handlerCode,
(SELECT e.entity_name
FROM AAAAAAAAAAA e
WHERE e.AAAAAAAAAAA = M.PRODUCTGRP_CODE
and e.top_code = 'BA10'
AND e.parent_code = '1') productgrpName,
M.DATASOURCE as DATASOURCE,
M.PRODUCTGRP_CODE as productgrpCode,
(select c.entity_name
from AAAAAAAAAAA c
where c.top_code = 'BA53'
and c.AAAAAAAAAAA = M.CHANNELCODE) as channelcode,
M.MID_CHANNELCODE as midChannelcode,
M.INSURE_WAY as insureWay,
M.AGENT_CODE as agentCode,
M.AGENT_NAME as agentName,
M.THE4S_CODE as the4sCode,
(select j.entity_name
from AAAAAAAAAAA j
where j.top_code = 'BA29'
and j.AAAAAAAAAAA = M.THE4S_CODE) as the4sName,
M.INSURED_NAME as insuredName,
M.APPLICANT_NAME as applicantName,
M.START_DATE as startDate,
M.END_DATE as endDate,
M.ISSUE_DATE as issueDate,
M.SUBPREMIUM as subpremium,
M.LICENSENO as licenseno,
(select u.entity_name
from AAAAAAAAAAA u
where u.top_code = 'BA28'
and u.AAAAAAAAAAA = M.USETYPE) as usetype,
M.VEHICLECLAIMTYPE as vehicleclaimtype,
M.ADDVALUETAX as addvaluetax,
M.AMOUNT_TYPE_I as amountTypeI,
M.AMOUNT_TYPE_II as amountTypeII,
M.AMOUNT_TYPE_III as amountTypeIII,
M.AMOUNT_TYPE_IV as amountTypeIV,
M.AMOUNT_TYPE_V as amountTypeV,
M.AMOUNT_OVERALL as amountOverall,
M.AMOUNT_OVERALL_TOTAL as amountOverallTotal,
M.AMOUNT_OVERALL_BRANCH as amountOverallBranch,
M.AMOUNT_OVERALL_DEPTGRP as amountOverallDeptgrp
from DDDDDDDDDDDD M
where 1 = 1
AND M.UNIQUE_CODE LIKE '3010100%'
AND M.LINE = '1'
AND M.CHANNELCODE IN ('C001', 'C002', 'C003', 'C004', 'C005', 'C006', 'C007',
'C008','C009','C010','CAND','C012','C013','C014','C015')
AND M.INSURE_WAY IN ('11','12','14','16','17','18','21',
'22','23','25','27','28','29','31','32','33','36','37','38','39','40',
'19','41','42','43','44','45','46','47','51')
AND M.BRANCH_CODE = '3010100'
AND ROWNUM <= 500000;

原SQL执行计划:

===============================================================
|ID|OPERATOR |NAME |EST. ROWS|COST |
---------------------------------------------------------------
|0 |SUBPLAN FILTER | |1938 |9646000|
|1 | TABLE SCAN |M(UNIQUE_CODE) |1938 |7260012|
|2 | TABLE SCAN |EC(UNI_AAAAAAAAAAA_02) |1 |137 |
|3 | SUBPLAN FILTER | |1 |274 |
|4 | TABLE SCAN |O(IND_BBBBBBBBBBBB_1) |1 |229 |
|5 | TABLE SCAN |Z(IND_BBBBBBBBBBBB_2) |4 |46 |
|6 | SUBPLAN FILTER | |1 |502 |
|7 | TABLE SCAN |O(IND_BBBBBBBBBBBB_1) |1 |229 |
|8 | SUBPLAN FILTER| |1 |274 |
|9 | TABLE SCAN |Z(IND_BBBBBBBBBBBB_1) |1 |229 |
|10| TABLE SCAN |I(IND_BBBBBBBBBBBB_2) |4 |46 |
|11| TABLE SCAN |E(IDX_CCCCCCCC_01) |1 |92 |
|12| TABLE SCAN |E(UNI_AAAAAAAAAAA_01) |1 |92 |
|13| TABLE SCAN |C(UNI_AAAAAAAAAAA_01) |1 |92 |
|14| TABLE SCAN |J(UNI_AAAAAAAAAAA_01) |1 |92 |
|15| TABLE SCAN |U(UNI_AAAAAAAAAAA_01) |1 |92 |
=============================================================== Outputs & filters:
-------------------------------------
0 - output([M.POLICY_CHARGE_ID], [M.POLICY_NO], [M.ENDORSE_NO], [?], [subquery(2)], [subquery(3)], [subquery(4)], [subquery(5)], [M.DATASOURCE], [M.PRODUCTGRP_CODE], [subquery(6)], [M.MID_CHANNELCODE], [M.INSURE_WAY], [M.AGENT_CODE], [M.AGENT_NAME], [M.THE4S_CODE], [subquery(7)], [M.INSURED_NAME], [M.APPLICANT_NAME], [M.START_DATE], [M.END_DATE], [M.ISSUE_DATE], [M.SUBPREMIUM], [M.LICENSENO], [subquery(8)], [M.VEHICLECLAIMTYPE], [M.ADDVALUETAX], [M.AMOUNT_TYPE_I], [M.AMOUNT_TYPE_II], [M.AMOUNT_TYPE_III], [M.AMOUNT_TYPE_IV], [M.AMOUNT_TYPE_V], [M.AMOUNT_OVERALL], [M.AMOUNT_OVERALL_TOTAL], [M.AMOUNT_OVERALL_BRANCH], [M.AMOUNT_OVERALL_DEPTGRP]), filter(nil),
exec_params_([M.DEPTGRP_CODE], [M.BRANCH_CODE], [M.DEPT_CODE], [M.DEPTGRP_CODE], [M.BRANCH_CODE], [M.HANDLER_CODE], [M.PRODUCTGRP_CODE], [M.CHANNELCODE], [M.THE4S_CODE], [M.USETYPE]), onetime_exprs_([subquery(1)]), init_plan_idxs_(nil)
1 - output([M.CHANNELCODE], [M.INSURE_WAY], [M.BRANCH_CODE], [M.POLICY_CHARGE_ID], [M.POLICY_NO], [M.ENDORSE_NO], [M.DEPTGRP_CODE], [M.DEPT_CODE], [M.HANDLER_CODE], [M.PRODUCTGRP_CODE], [M.DATASOURCE], [M.MID_CHANNELCODE], [M.AGENT_CODE], [M.AGENT_NAME], [M.THE4S_CODE], [M.INSURED_NAME], [M.APPLICANT_NAME], [M.START_DATE], [M.END_DATE], [M.ISSUE_DATE], [M.SUBPREMIUM], [M.LICENSENO], [M.USETYPE], [M.VEHICLECLAIMTYPE], [M.ADDVALUETAX], [M.AMOUNT_TYPE_I], [M.AMOUNT_TYPE_II], [M.AMOUNT_TYPE_III], [M.AMOUNT_TYPE_IV], [M.AMOUNT_TYPE_V], [M.AMOUNT_OVERALL], [M.AMOUNT_OVERALL_TOTAL], [M.AMOUNT_OVERALL_BRANCH], [M.AMOUNT_OVERALL_DEPTGRP]), filter([M.BRANCH_CODE = ?], [M.LINE = ?], [M.CHANNELCODE IN (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)], [M.INSURE_WAY IN (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)]),
access([M.LINE], [M.CHANNELCODE], [M.INSURE_WAY], [M.BRANCH_CODE], [M.POLICY_CHARGE_ID], [M.POLICY_NO], [M.ENDORSE_NO], [M.DEPTGRP_CODE], [M.DEPT_CODE], [M.HANDLER_CODE], [M.PRODUCTGRP_CODE], [M.DATASOURCE], [M.MID_CHANNELCODE], [M.AGENT_CODE], [M.AGENT_NAME], [M.THE4S_CODE], [M.INSURED_NAME], [M.APPLICANT_NAME], [M.START_DATE], [M.END_DATE], [M.ISSUE_DATE], [M.SUBPREMIUM], [M.LICENSENO], [M.USETYPE], [M.VEHICLECLAIMTYPE], [M.ADDVALUETAX], [M.AMOUNT_TYPE_I], [M.AMOUNT_TYPE_II], [M.AMOUNT_TYPE_III], [M.AMOUNT_TYPE_IV], [M.AMOUNT_TYPE_V], [M.AMOUNT_OVERALL], [M.AMOUNT_OVERALL_TOTAL], [M.AMOUNT_OVERALL_BRANCH], [M.AMOUNT_OVERALL_DEPTGRP]), partitions(p0),
limit(?), offset(nil)
2 - output([EC.ENTITY_NAME]), filter([EC.AAAAAAAAAAA = ?]),
access([EC.AAAAAAAAAAA], [EC.ENTITY_NAME]), partitions(p0)
3 - output([O.NAME]), filter(nil),
exec_params_(nil), onetime_exprs_([subquery(1)]), init_plan_idxs_(nil)
4 - output([O.NAME]), filter([O.CODE = ?]),
access([O.CODE], [O.NAME]), partitions(p0)
5 - output([Z.ORG_ID]), filter(nil),
access([Z.ORG_ID]), partitions(p0)
6 - output([O.NAME]), filter(nil),
exec_params_(nil), onetime_exprs_([subquery(1)]), init_plan_idxs_(nil)
7 - output([O.NAME]), filter([O.CODE = ?]),
access([O.CODE], [O.NAME]), partitions(p0)
8 - output([Z.ORG_ID]), filter(nil),
exec_params_(nil), onetime_exprs_([subquery(1)]), init_plan_idxs_(nil)
9 - output([Z.ORG_ID]), filter([Z.CODE = ?]),
access([Z.CODE], [Z.ORG_ID]), partitions(p0)
10 - output([I.ORG_ID]), filter(nil),
access([I.ORG_ID]), partitions(p0)
11 - output([E.NAME]), filter(nil),
access([E.NAME]), partitions(p0)
12 - output([E.ENTITY_NAME]), filter([E.PARENT_CODE = ?]),
access([E.PARENT_CODE], [E.ENTITY_NAME]), partitions(p0)
13 - output([C.ENTITY_NAME]), filter(nil),
access([C.ENTITY_NAME]), partitions(p0)
14 - output([J.ENTITY_NAME]), filter(nil),
access([J.ENTITY_NAME]), partitions(p0)
15 - output([U.ENTITY_NAME]), filter(nil),
access([U.ENTITY_NAME]), partitions(p0)

执行时间:

其实刚拿到SQL大致看了一遍就知道哪里慢(OB的执行计划其实我也看不懂),标量子查询过多导致的filter。

主表 CC_POLICY_CHARGE M 共430多万行数据,只取50W出来(ROWNUM <= 500000)。

在OB上跑要 3184S(50多分钟) 出结果,而在ORACLE 只需要 1010s 就能跑出结果,可见ORACLE的CBO优化器是多强大,太顶了。

像这种SQL要优化只能等价改写(把标量子查询改成 left join 干掉 filter),无其他办法:

等价改写SQL:

SELECT M.POLICY_CHARGE_ID       AS policyChargeId,
M.POLICY_NO AS policyNo,
M.ENDORSE_NO AS endorseNo,
EC.entity_name AS line,
O1.name AS deptgrpCode,
O2.name AS deptCode,
E.name AS handlerCode,
EC2.entity_name AS productgrpName,
M.DATASOURCE AS DATASOURCE,
M.PRODUCTGRP_CODE AS productgrpCode,
EC3.entity_name AS channelcode,
M.MID_CHANNELCODE AS midChannelcode,
M.INSURE_WAY AS insureWay,
M.AGENT_CODE AS agentCode,
M.AGENT_NAME AS agentName,
M.THE4S_CODE AS the4sCode,
EC4.entity_name AS the4sName,
M.INSURED_NAME AS insuredName,
M.APPLICANT_NAME AS applicantName,
M.START_DATE AS startDate,
M.END_DATE AS endDate,
M.ISSUE_DATE AS issueDate,
M.SUBPREMIUM AS subpremium,
M.LICENSENO AS licenseno,
EC5.entity_name AS usetype,
M.VEHICLECLAIMTYPE AS vehicleclaimtype,
M.ADDVALUETAX AS addvaluetax,
M.AMOUNT_TYPE_I AS amountTypeI,
M.AMOUNT_TYPE_II AS amountTypeII,
M.AMOUNT_TYPE_III AS amountTypeIII,
M.AMOUNT_TYPE_IV AS amountTypeIV,
M.AMOUNT_TYPE_V AS amountTypeV,
M.AMOUNT_OVERALL AS amountOverall,
M.AMOUNT_OVERALL_TOTAL AS amountOverallTotal,
M.AMOUNT_OVERALL_BRANCH AS amountOverallBranch,
M.AMOUNT_OVERALL_DEPTGRP AS amountOverallDeptgrp
FROM DDDDDDDDDDDD M
LEFT JOIN AAAAAAAAAAA EC ON EC.parent_code = 'BA36' AND EC.AAAAAAAAAAA = M.line
LEFT JOIN BBBBBBBBBBBB O1 ON O1.code = M.DEPTGRP_CODE
LEFT JOIN BBBBBBBBBBBB O1_PARENT ON O1_PARENT.code = M.BRANCH_CODE AND O1_PARENT.org_id = O1.parent_id
LEFT JOIN BBBBBBBBBBBB O2 ON O2.code = M.DEPT_CODE
LEFT JOIN BBBBBBBBBBBB O2_PARENT ON O2_PARENT.code = M.DEPTGRP_CODE AND O2_PARENT.org_id = O2.parent_id
LEFT JOIN BBBBBBBBBBBB O2_GRANDPARENT
ON O2_GRANDPARENT.code = M.BRANCH_CODE AND O2_GRANDPARENT.org_id = O2_PARENT.parent_id
LEFT JOIN CCCCCCCC E ON E.code = M.HANDLER_CODE AND E.unit_code = M.Branch_Code
LEFT JOIN AAAAAAAAAAA EC2
ON EC2.AAAAAAAAAAA = M.PRODUCTGRP_CODE AND EC2.top_code = 'BA10' AND EC2.parent_code = '1'
LEFT JOIN AAAAAAAAAAA EC3 ON EC3.top_code = 'BA53' AND EC3.AAAAAAAAAAA = M.CHANNELCODE
LEFT JOIN AAAAAAAAAAA EC4 ON EC4.top_code = 'BA29' AND EC4.AAAAAAAAAAA = M.THE4S_CODE
LEFT JOIN AAAAAAAAAAA EC5 ON EC5.top_code = 'BA28' AND EC5.AAAAAAAAAAA = M.USETYPE
WHERE 1 = 1
AND M.UNIQUE_CODE LIKE '3010100%'
AND M.LINE = '1'
AND M.CHANNELCODE IN ('C001', 'C002', 'C003', 'C004', 'C005', 'C006', 'C007',
'C008','C009','C010','CAND','C012','C013','C014','C015')
AND M.INSURE_WAY IN ('11','12','14','16','17','18','21',
'22','23','25','27','28','29','31','32','33','36','37','38','39','40',
'19','41','42','43','44','45','46','47','51')
AND M.BRANCH_CODE = '3010100'
AND ROWNUM <= 500000;

改写后的执行计划:

=============================================================================================
|ID|OPERATOR |NAME |EST. ROWS|COST |
---------------------------------------------------------------------------------------------
|0 |LIMIT | |34690 |7739035|
|1 | MERGE OUTER JOIN | |34690 |7738513|
|2 | HASH RIGHT OUTER JOIN | |34690 |7737851|
|3 | TABLE SCAN |EC2(UNI_AAAAAAAAAAA_02) |1 |183 |
|4 | HASH RIGHT OUTER JOIN | |34690 |7715121|
|5 | TABLE SCAN |EC3(INDEX_ENTITY_TOPCODE) |16 |183 |
|6 | HASH RIGHT OUTER JOIN | |34690 |7684751|
|7 | TABLE SCAN |EC5(INDEX_ENTITY_TOPCODE) |32 |184 |
|8 | HASH RIGHT OUTER JOIN | |34690 |7654365|
|9 | TABLE SCAN |EC4(INDEX_ENTITY_TOPCODE) |2 |137 |
|10| HASH RIGHT OUTER JOIN | |34690 |7631719|
|11| TABLE SCAN |O2_GRANDPARENT(IND_BBBBBBBBBBBB_2) |1 |46 |
|12| HASH RIGHT OUTER JOIN | |34690 |7608424|
|13| TABLE SCAN |O1_PARENT(IND_BBBBBBBBBBBB_2) |1 |46 |
|14| HASH RIGHT OUTER JOIN | |34690 |7585128|
|15| TABLE SCAN |O2_PARENT |65935 |25504 |
|16| HASH OUTER JOIN | |34690 |7482018|
|17| HASH OUTER JOIN | |9764 |7387204|
|18| NESTED-LOOP OUTER JOIN| |2748 |7311954|
|19| SUBPLAN SCAN |VIEW2 |1938 |7260041|
|20| TABLE SCAN |M(UNIQUE_CODE) |1938 |7260012|
|21| TABLE SCAN |E(IDX_CCCCCCCC_01) |1 |26 |
|22| TABLE SCAN |O1 |65935 |25504 |
|23| TABLE SCAN |O2 |65935 |25504 |
|24| TABLE SCAN |EC(UNI_AAAAAAAAAAA_02) |1 |137 |
============================================================================================= Outputs & filters:
-------------------------------------
0 - output([VIEW2.M.POLICY_CHARGE_ID], [VIEW2.M.POLICY_NO], [VIEW2.M.ENDORSE_NO], [EC.ENTITY_NAME], [O1.NAME], [O2.NAME], [E.NAME], [EC2.ENTITY_NAME], [VIEW2.M.DATASOURCE], [VIEW2.M.PRODUCTGRP_CODE], [EC3.ENTITY_NAME], [VIEW2.M.MID_CHANNELCODE], [VIEW2.M.INSURE_WAY], [VIEW2.M.AGENT_CODE], [VIEW2.M.AGENT_NAME], [VIEW2.M.THE4S_CODE], [EC4.ENTITY_NAME], [VIEW2.M.INSURED_NAME], [VIEW2.M.APPLICANT_NAME], [VIEW2.M.START_DATE], [VIEW2.M.END_DATE], [VIEW2.M.ISSUE_DATE], [VIEW2.M.SUBPREMIUM], [VIEW2.M.LICENSENO], [EC5.ENTITY_NAME], [VIEW2.M.VEHICLECLAIMTYPE], [VIEW2.M.ADDVALUETAX], [VIEW2.M.AMOUNT_TYPE_I], [VIEW2.M.AMOUNT_TYPE_II], [VIEW2.M.AMOUNT_TYPE_III], [VIEW2.M.AMOUNT_TYPE_IV], [VIEW2.M.AMOUNT_TYPE_V], [VIEW2.M.AMOUNT_OVERALL], [VIEW2.M.AMOUNT_OVERALL_TOTAL], [VIEW2.M.AMOUNT_OVERALL_BRANCH], [VIEW2.M.AMOUNT_OVERALL_DEPTGRP]), filter(nil), limit(?), offset(nil)
1 - output([VIEW2.M.POLICY_CHARGE_ID], [VIEW2.M.POLICY_NO], [VIEW2.M.ENDORSE_NO], [EC.ENTITY_NAME], [O1.NAME], [O2.NAME], [E.NAME], [EC2.ENTITY_NAME], [VIEW2.M.DATASOURCE], [VIEW2.M.PRODUCTGRP_CODE], [EC3.ENTITY_NAME], [VIEW2.M.MID_CHANNELCODE], [VIEW2.M.INSURE_WAY], [VIEW2.M.AGENT_CODE], [VIEW2.M.AGENT_NAME], [VIEW2.M.THE4S_CODE], [EC4.ENTITY_NAME], [VIEW2.M.INSURED_NAME], [VIEW2.M.APPLICANT_NAME], [VIEW2.M.START_DATE], [VIEW2.M.END_DATE], [VIEW2.M.ISSUE_DATE], [VIEW2.M.SUBPREMIUM], [VIEW2.M.LICENSENO], [EC5.ENTITY_NAME], [VIEW2.M.VEHICLECLAIMTYPE], [VIEW2.M.ADDVALUETAX], [VIEW2.M.AMOUNT_TYPE_I], [VIEW2.M.AMOUNT_TYPE_II], [VIEW2.M.AMOUNT_TYPE_III], [VIEW2.M.AMOUNT_TYPE_IV], [VIEW2.M.AMOUNT_TYPE_V], [VIEW2.M.AMOUNT_OVERALL], [VIEW2.M.AMOUNT_OVERALL_TOTAL], [VIEW2.M.AMOUNT_OVERALL_BRANCH], [VIEW2.M.AMOUNT_OVERALL_DEPTGRP]), filter(nil),
equal_conds([EC.AAAAAAAAAAA = VIEW2.M.LINE]), other_conds(nil)
2 - output([VIEW2.M.POLICY_CHARGE_ID], [VIEW2.M.POLICY_NO], [VIEW2.M.ENDORSE_NO], [O1.NAME], [O2.NAME], [E.NAME], [EC2.ENTITY_NAME], [VIEW2.M.DATASOURCE], [VIEW2.M.PRODUCTGRP_CODE], [EC3.ENTITY_NAME], [VIEW2.M.MID_CHANNELCODE], [VIEW2.M.INSURE_WAY], [VIEW2.M.AGENT_CODE], [VIEW2.M.AGENT_NAME], [VIEW2.M.THE4S_CODE], [EC4.ENTITY_NAME], [VIEW2.M.INSURED_NAME], [VIEW2.M.APPLICANT_NAME], [VIEW2.M.START_DATE], [VIEW2.M.END_DATE], [VIEW2.M.ISSUE_DATE], [VIEW2.M.SUBPREMIUM], [VIEW2.M.LICENSENO], [EC5.ENTITY_NAME], [VIEW2.M.VEHICLECLAIMTYPE], [VIEW2.M.ADDVALUETAX], [VIEW2.M.AMOUNT_TYPE_I], [VIEW2.M.AMOUNT_TYPE_II], [VIEW2.M.AMOUNT_TYPE_III], [VIEW2.M.AMOUNT_TYPE_IV], [VIEW2.M.AMOUNT_TYPE_V], [VIEW2.M.AMOUNT_OVERALL], [VIEW2.M.AMOUNT_OVERALL_TOTAL], [VIEW2.M.AMOUNT_OVERALL_BRANCH], [VIEW2.M.AMOUNT_OVERALL_DEPTGRP], [VIEW2.M.LINE]), filter(nil),
equal_conds([EC2.AAAAAAAAAAA = VIEW2.M.PRODUCTGRP_CODE]), other_conds(nil)
3 - output([EC2.AAAAAAAAAAA], [EC2.ENTITY_NAME]), filter([EC2.TOP_CODE = ?]),
access([EC2.AAAAAAAAAAA], [EC2.TOP_CODE], [EC2.ENTITY_NAME]), partitions(p0)
4 - output([VIEW2.M.POLICY_CHARGE_ID], [VIEW2.M.POLICY_NO], [VIEW2.M.ENDORSE_NO], [O1.NAME], [O2.NAME], [E.NAME], [VIEW2.M.DATASOURCE], [VIEW2.M.PRODUCTGRP_CODE], [EC3.ENTITY_NAME], [VIEW2.M.MID_CHANNELCODE], [VIEW2.M.INSURE_WAY], [VIEW2.M.AGENT_CODE], [VIEW2.M.AGENT_NAME], [VIEW2.M.THE4S_CODE], [EC4.ENTITY_NAME], [VIEW2.M.INSURED_NAME], [VIEW2.M.APPLICANT_NAME], [VIEW2.M.START_DATE], [VIEW2.M.END_DATE], [VIEW2.M.ISSUE_DATE], [VIEW2.M.SUBPREMIUM], [VIEW2.M.LICENSENO], [EC5.ENTITY_NAME], [VIEW2.M.VEHICLECLAIMTYPE], [VIEW2.M.ADDVALUETAX], [VIEW2.M.AMOUNT_TYPE_I], [VIEW2.M.AMOUNT_TYPE_II], [VIEW2.M.AMOUNT_TYPE_III], [VIEW2.M.AMOUNT_TYPE_IV], [VIEW2.M.AMOUNT_TYPE_V], [VIEW2.M.AMOUNT_OVERALL], [VIEW2.M.AMOUNT_OVERALL_TOTAL], [VIEW2.M.AMOUNT_OVERALL_BRANCH], [VIEW2.M.AMOUNT_OVERALL_DEPTGRP], [VIEW2.M.LINE]), filter(nil),
equal_conds([EC3.AAAAAAAAAAA = VIEW2.M.CHANNELCODE]), other_conds(nil)
5 - output([EC3.AAAAAAAAAAA], [EC3.ENTITY_NAME]), filter(nil),
access([EC3.AAAAAAAAAAA], [EC3.ENTITY_NAME]), partitions(p0)
6 - output([VIEW2.M.POLICY_CHARGE_ID], [VIEW2.M.POLICY_NO], [VIEW2.M.ENDORSE_NO], [O1.NAME], [O2.NAME], [E.NAME], [VIEW2.M.DATASOURCE], [VIEW2.M.PRODUCTGRP_CODE], [VIEW2.M.MID_CHANNELCODE], [VIEW2.M.INSURE_WAY], [VIEW2.M.AGENT_CODE], [VIEW2.M.AGENT_NAME], [VIEW2.M.THE4S_CODE], [EC4.ENTITY_NAME], [VIEW2.M.INSURED_NAME], [VIEW2.M.APPLICANT_NAME], [VIEW2.M.START_DATE], [VIEW2.M.END_DATE], [VIEW2.M.ISSUE_DATE], [VIEW2.M.SUBPREMIUM], [VIEW2.M.LICENSENO], [EC5.ENTITY_NAME], [VIEW2.M.VEHICLECLAIMTYPE], [VIEW2.M.ADDVALUETAX], [VIEW2.M.AMOUNT_TYPE_I], [VIEW2.M.AMOUNT_TYPE_II], [VIEW2.M.AMOUNT_TYPE_III], [VIEW2.M.AMOUNT_TYPE_IV], [VIEW2.M.AMOUNT_TYPE_V], [VIEW2.M.AMOUNT_OVERALL], [VIEW2.M.AMOUNT_OVERALL_TOTAL], [VIEW2.M.AMOUNT_OVERALL_BRANCH], [VIEW2.M.AMOUNT_OVERALL_DEPTGRP], [VIEW2.M.LINE], [VIEW2.M.CHANNELCODE]), filter(nil),
equal_conds([EC5.AAAAAAAAAAA = VIEW2.M.USETYPE]), other_conds(nil)
7 - output([EC5.AAAAAAAAAAA], [EC5.ENTITY_NAME]), filter(nil),
access([EC5.AAAAAAAAAAA], [EC5.ENTITY_NAME]), partitions(p0)
8 - output([VIEW2.M.POLICY_CHARGE_ID], [VIEW2.M.POLICY_NO], [VIEW2.M.ENDORSE_NO], [O1.NAME], [O2.NAME], [E.NAME], [VIEW2.M.DATASOURCE], [VIEW2.M.PRODUCTGRP_CODE], [VIEW2.M.MID_CHANNELCODE], [VIEW2.M.INSURE_WAY], [VIEW2.M.AGENT_CODE], [VIEW2.M.AGENT_NAME], [VIEW2.M.THE4S_CODE], [EC4.ENTITY_NAME], [VIEW2.M.INSURED_NAME], [VIEW2.M.APPLICANT_NAME], [VIEW2.M.START_DATE], [VIEW2.M.END_DATE], [VIEW2.M.ISSUE_DATE], [VIEW2.M.SUBPREMIUM], [VIEW2.M.LICENSENO], [VIEW2.M.VEHICLECLAIMTYPE], [VIEW2.M.ADDVALUETAX], [VIEW2.M.AMOUNT_TYPE_I], [VIEW2.M.AMOUNT_TYPE_II], [VIEW2.M.AMOUNT_TYPE_III], [VIEW2.M.AMOUNT_TYPE_IV], [VIEW2.M.AMOUNT_TYPE_V], [VIEW2.M.AMOUNT_OVERALL], [VIEW2.M.AMOUNT_OVERALL_TOTAL], [VIEW2.M.AMOUNT_OVERALL_BRANCH], [VIEW2.M.AMOUNT_OVERALL_DEPTGRP], [VIEW2.M.LINE], [VIEW2.M.CHANNELCODE], [VIEW2.M.USETYPE]), filter(nil),
equal_conds([EC4.AAAAAAAAAAA = VIEW2.M.THE4S_CODE]), other_conds(nil)
9 - output([EC4.AAAAAAAAAAA], [EC4.ENTITY_NAME]), filter(nil),
access([EC4.AAAAAAAAAAA], [EC4.ENTITY_NAME]), partitions(p0)
10 - output([VIEW2.M.POLICY_CHARGE_ID], [VIEW2.M.POLICY_NO], [VIEW2.M.ENDORSE_NO], [O1.NAME], [O2.NAME], [E.NAME], [VIEW2.M.DATASOURCE], [VIEW2.M.PRODUCTGRP_CODE], [VIEW2.M.MID_CHANNELCODE], [VIEW2.M.INSURE_WAY], [VIEW2.M.AGENT_CODE], [VIEW2.M.AGENT_NAME], [VIEW2.M.THE4S_CODE], [VIEW2.M.INSURED_NAME], [VIEW2.M.APPLICANT_NAME], [VIEW2.M.START_DATE], [VIEW2.M.END_DATE], [VIEW2.M.ISSUE_DATE], [VIEW2.M.SUBPREMIUM], [VIEW2.M.LICENSENO], [VIEW2.M.VEHICLECLAIMTYPE], [VIEW2.M.ADDVALUETAX], [VIEW2.M.AMOUNT_TYPE_I], [VIEW2.M.AMOUNT_TYPE_II], [VIEW2.M.AMOUNT_TYPE_III], [VIEW2.M.AMOUNT_TYPE_IV], [VIEW2.M.AMOUNT_TYPE_V], [VIEW2.M.AMOUNT_OVERALL], [VIEW2.M.AMOUNT_OVERALL_TOTAL], [VIEW2.M.AMOUNT_OVERALL_BRANCH], [VIEW2.M.AMOUNT_OVERALL_DEPTGRP], [VIEW2.M.LINE], [VIEW2.M.CHANNELCODE], [VIEW2.M.USETYPE]), filter(nil),
equal_conds([O2_GRANDPARENT.CODE = VIEW2.M.BRANCH_CODE], [O2_GRANDPARENT.ORG_ID = O2_PARENT.PARENT_ID]), other_conds(nil)
11 - output([O2_GRANDPARENT.CODE], [O2_GRANDPARENT.ORG_ID]), filter(nil),
access([O2_GRANDPARENT.CODE], [O2_GRANDPARENT.ORG_ID]), partitions(p0)
12 - output([VIEW2.M.POLICY_CHARGE_ID], [VIEW2.M.POLICY_NO], [VIEW2.M.ENDORSE_NO], [O1.NAME], [O2.NAME], [E.NAME], [VIEW2.M.DATASOURCE], [VIEW2.M.PRODUCTGRP_CODE], [VIEW2.M.MID_CHANNELCODE], [VIEW2.M.INSURE_WAY], [VIEW2.M.AGENT_CODE], [VIEW2.M.AGENT_NAME], [VIEW2.M.THE4S_CODE], [VIEW2.M.INSURED_NAME], [VIEW2.M.APPLICANT_NAME], [VIEW2.M.START_DATE], [VIEW2.M.END_DATE], [VIEW2.M.ISSUE_DATE], [VIEW2.M.SUBPREMIUM], [VIEW2.M.LICENSENO], [VIEW2.M.VEHICLECLAIMTYPE], [VIEW2.M.ADDVALUETAX], [VIEW2.M.AMOUNT_TYPE_I], [VIEW2.M.AMOUNT_TYPE_II], [VIEW2.M.AMOUNT_TYPE_III], [VIEW2.M.AMOUNT_TYPE_IV], [VIEW2.M.AMOUNT_TYPE_V], [VIEW2.M.AMOUNT_OVERALL], [VIEW2.M.AMOUNT_OVERALL_TOTAL], [VIEW2.M.AMOUNT_OVERALL_BRANCH], [VIEW2.M.AMOUNT_OVERALL_DEPTGRP], [VIEW2.M.LINE], [VIEW2.M.CHANNELCODE], [VIEW2.M.USETYPE], [VIEW2.M.BRANCH_CODE], [O2_PARENT.PARENT_ID]), filter(nil),
equal_conds([O1_PARENT.CODE = VIEW2.M.BRANCH_CODE], [O1_PARENT.ORG_ID = O1.PARENT_ID]), other_conds(nil)
13 - output([O1_PARENT.CODE], [O1_PARENT.ORG_ID]), filter(nil),
access([O1_PARENT.CODE], [O1_PARENT.ORG_ID]), partitions(p0)
14 - output([VIEW2.M.POLICY_CHARGE_ID], [VIEW2.M.POLICY_NO], [VIEW2.M.ENDORSE_NO], [O1.NAME], [O2.NAME], [E.NAME], [VIEW2.M.DATASOURCE], [VIEW2.M.PRODUCTGRP_CODE], [VIEW2.M.MID_CHANNELCODE], [VIEW2.M.INSURE_WAY], [VIEW2.M.AGENT_CODE], [VIEW2.M.AGENT_NAME], [VIEW2.M.THE4S_CODE], [VIEW2.M.INSURED_NAME], [VIEW2.M.APPLICANT_NAME], [VIEW2.M.START_DATE], [VIEW2.M.END_DATE], [VIEW2.M.ISSUE_DATE], [VIEW2.M.SUBPREMIUM], [VIEW2.M.LICENSENO], [VIEW2.M.VEHICLECLAIMTYPE], [VIEW2.M.ADDVALUETAX], [VIEW2.M.AMOUNT_TYPE_I], [VIEW2.M.AMOUNT_TYPE_II], [VIEW2.M.AMOUNT_TYPE_III], [VIEW2.M.AMOUNT_TYPE_IV], [VIEW2.M.AMOUNT_TYPE_V], [VIEW2.M.AMOUNT_OVERALL], [VIEW2.M.AMOUNT_OVERALL_TOTAL], [VIEW2.M.AMOUNT_OVERALL_BRANCH], [VIEW2.M.AMOUNT_OVERALL_DEPTGRP], [VIEW2.M.LINE], [VIEW2.M.CHANNELCODE], [VIEW2.M.USETYPE], [VIEW2.M.BRANCH_CODE], [O2_PARENT.PARENT_ID], [O1.PARENT_ID]), filter(nil),
equal_conds([O2_PARENT.CODE = VIEW2.M.DEPTGRP_CODE], [O2_PARENT.ORG_ID = O2.PARENT_ID]), other_conds(nil)
15 - output([O2_PARENT.CODE], [O2_PARENT.ORG_ID], [O2_PARENT.PARENT_ID]), filter(nil),
access([O2_PARENT.CODE], [O2_PARENT.ORG_ID], [O2_PARENT.PARENT_ID]), partitions(p0)
16 - output([VIEW2.M.POLICY_CHARGE_ID], [VIEW2.M.POLICY_NO], [VIEW2.M.ENDORSE_NO], [O1.NAME], [O2.NAME], [E.NAME], [VIEW2.M.DATASOURCE], [VIEW2.M.PRODUCTGRP_CODE], [VIEW2.M.MID_CHANNELCODE], [VIEW2.M.INSURE_WAY], [VIEW2.M.AGENT_CODE], [VIEW2.M.AGENT_NAME], [VIEW2.M.THE4S_CODE], [VIEW2.M.INSURED_NAME], [VIEW2.M.APPLICANT_NAME], [VIEW2.M.START_DATE], [VIEW2.M.END_DATE], [VIEW2.M.ISSUE_DATE], [VIEW2.M.SUBPREMIUM], [VIEW2.M.LICENSENO], [VIEW2.M.VEHICLECLAIMTYPE], [VIEW2.M.ADDVALUETAX], [VIEW2.M.AMOUNT_TYPE_I], [VIEW2.M.AMOUNT_TYPE_II], [VIEW2.M.AMOUNT_TYPE_III], [VIEW2.M.AMOUNT_TYPE_IV], [VIEW2.M.AMOUNT_TYPE_V], [VIEW2.M.AMOUNT_OVERALL], [VIEW2.M.AMOUNT_OVERALL_TOTAL], [VIEW2.M.AMOUNT_OVERALL_BRANCH], [VIEW2.M.AMOUNT_OVERALL_DEPTGRP], [VIEW2.M.LINE], [VIEW2.M.CHANNELCODE], [VIEW2.M.USETYPE], [VIEW2.M.BRANCH_CODE], [O1.PARENT_ID], [VIEW2.M.DEPTGRP_CODE], [O2.PARENT_ID]), filter(nil),
equal_conds([O2.CODE = VIEW2.M.DEPT_CODE]), other_conds(nil)
17 - output([VIEW2.M.POLICY_CHARGE_ID], [VIEW2.M.POLICY_NO], [VIEW2.M.ENDORSE_NO], [O1.NAME], [E.NAME], [VIEW2.M.DATASOURCE], [VIEW2.M.PRODUCTGRP_CODE], [VIEW2.M.MID_CHANNELCODE], [VIEW2.M.INSURE_WAY], [VIEW2.M.AGENT_CODE], [VIEW2.M.AGENT_NAME], [VIEW2.M.THE4S_CODE], [VIEW2.M.INSURED_NAME], [VIEW2.M.APPLICANT_NAME], [VIEW2.M.START_DATE], [VIEW2.M.END_DATE], [VIEW2.M.ISSUE_DATE], [VIEW2.M.SUBPREMIUM], [VIEW2.M.LICENSENO], [VIEW2.M.VEHICLECLAIMTYPE], [VIEW2.M.ADDVALUETAX], [VIEW2.M.AMOUNT_TYPE_I], [VIEW2.M.AMOUNT_TYPE_II], [VIEW2.M.AMOUNT_TYPE_III], [VIEW2.M.AMOUNT_TYPE_IV], [VIEW2.M.AMOUNT_TYPE_V], [VIEW2.M.AMOUNT_OVERALL], [VIEW2.M.AMOUNT_OVERALL_TOTAL], [VIEW2.M.AMOUNT_OVERALL_BRANCH], [VIEW2.M.AMOUNT_OVERALL_DEPTGRP], [VIEW2.M.LINE], [VIEW2.M.CHANNELCODE], [VIEW2.M.USETYPE], [VIEW2.M.BRANCH_CODE], [O1.PARENT_ID], [VIEW2.M.DEPTGRP_CODE], [VIEW2.M.DEPT_CODE]), filter(nil),
equal_conds([O1.CODE = VIEW2.M.DEPTGRP_CODE]), other_conds(nil)
18 - output([VIEW2.M.POLICY_CHARGE_ID], [VIEW2.M.POLICY_NO], [VIEW2.M.ENDORSE_NO], [E.NAME], [VIEW2.M.DATASOURCE], [VIEW2.M.PRODUCTGRP_CODE], [VIEW2.M.MID_CHANNELCODE], [VIEW2.M.INSURE_WAY], [VIEW2.M.AGENT_CODE], [VIEW2.M.AGENT_NAME], [VIEW2.M.THE4S_CODE], [VIEW2.M.INSURED_NAME], [VIEW2.M.APPLICANT_NAME], [VIEW2.M.START_DATE], [VIEW2.M.END_DATE], [VIEW2.M.ISSUE_DATE], [VIEW2.M.SUBPREMIUM], [VIEW2.M.LICENSENO], [VIEW2.M.VEHICLECLAIMTYPE], [VIEW2.M.ADDVALUETAX], [VIEW2.M.AMOUNT_TYPE_I], [VIEW2.M.AMOUNT_TYPE_II], [VIEW2.M.AMOUNT_TYPE_III], [VIEW2.M.AMOUNT_TYPE_IV], [VIEW2.M.AMOUNT_TYPE_V], [VIEW2.M.AMOUNT_OVERALL], [VIEW2.M.AMOUNT_OVERALL_TOTAL], [VIEW2.M.AMOUNT_OVERALL_BRANCH], [VIEW2.M.AMOUNT_OVERALL_DEPTGRP], [VIEW2.M.LINE], [VIEW2.M.CHANNELCODE], [VIEW2.M.USETYPE], [VIEW2.M.BRANCH_CODE], [VIEW2.M.DEPTGRP_CODE], [VIEW2.M.DEPT_CODE]), filter(nil),
conds(nil), nl_params_([VIEW2.M.HANDLER_CODE], [VIEW2.M.BRANCH_CODE])
19 - output([VIEW2.M.LINE], [VIEW2.M.DEPTGRP_CODE], [VIEW2.M.BRANCH_CODE], [VIEW2.M.DEPT_CODE], [VIEW2.M.HANDLER_CODE], [VIEW2.M.PRODUCTGRP_CODE], [VIEW2.M.CHANNELCODE], [VIEW2.M.THE4S_CODE], [VIEW2.M.USETYPE], [VIEW2.M.INSURE_WAY], [VIEW2.M.POLICY_CHARGE_ID], [VIEW2.M.POLICY_NO], [VIEW2.M.ENDORSE_NO], [VIEW2.M.DATASOURCE], [VIEW2.M.MID_CHANNELCODE], [VIEW2.M.AGENT_CODE], [VIEW2.M.AGENT_NAME], [VIEW2.M.INSURED_NAME], [VIEW2.M.APPLICANT_NAME], [VIEW2.M.START_DATE], [VIEW2.M.END_DATE], [VIEW2.M.ISSUE_DATE], [VIEW2.M.SUBPREMIUM], [VIEW2.M.LICENSENO], [VIEW2.M.VEHICLECLAIMTYPE], [VIEW2.M.ADDVALUETAX], [VIEW2.M.AMOUNT_TYPE_I], [VIEW2.M.AMOUNT_TYPE_II], [VIEW2.M.AMOUNT_TYPE_III], [VIEW2.M.AMOUNT_TYPE_IV], [VIEW2.M.AMOUNT_TYPE_V], [VIEW2.M.AMOUNT_OVERALL], [VIEW2.M.AMOUNT_OVERALL_TOTAL], [VIEW2.M.AMOUNT_OVERALL_BRANCH], [VIEW2.M.AMOUNT_OVERALL_DEPTGRP]), filter(nil),
access([VIEW2.M.LINE], [VIEW2.M.DEPTGRP_CODE], [VIEW2.M.BRANCH_CODE], [VIEW2.M.DEPT_CODE], [VIEW2.M.HANDLER_CODE], [VIEW2.M.PRODUCTGRP_CODE], [VIEW2.M.CHANNELCODE], [VIEW2.M.THE4S_CODE], [VIEW2.M.USETYPE], [VIEW2.M.INSURE_WAY], [VIEW2.M.POLICY_CHARGE_ID], [VIEW2.M.POLICY_NO], [VIEW2.M.ENDORSE_NO], [VIEW2.M.DATASOURCE], [VIEW2.M.MID_CHANNELCODE], [VIEW2.M.AGENT_CODE], [VIEW2.M.AGENT_NAME], [VIEW2.M.INSURED_NAME], [VIEW2.M.APPLICANT_NAME], [VIEW2.M.START_DATE], [VIEW2.M.END_DATE], [VIEW2.M.ISSUE_DATE], [VIEW2.M.SUBPREMIUM], [VIEW2.M.LICENSENO], [VIEW2.M.VEHICLECLAIMTYPE], [VIEW2.M.ADDVALUETAX], [VIEW2.M.AMOUNT_TYPE_I], [VIEW2.M.AMOUNT_TYPE_II], [VIEW2.M.AMOUNT_TYPE_III], [VIEW2.M.AMOUNT_TYPE_IV], [VIEW2.M.AMOUNT_TYPE_V], [VIEW2.M.AMOUNT_OVERALL], [VIEW2.M.AMOUNT_OVERALL_TOTAL], [VIEW2.M.AMOUNT_OVERALL_BRANCH], [VIEW2.M.AMOUNT_OVERALL_DEPTGRP])
20 - output([M.LINE], [M.DEPTGRP_CODE], [M.BRANCH_CODE], [M.DEPT_CODE], [M.HANDLER_CODE], [M.PRODUCTGRP_CODE], [M.CHANNELCODE], [M.THE4S_CODE], [M.USETYPE], [M.INSURE_WAY], [M.POLICY_CHARGE_ID], [M.POLICY_NO], [M.ENDORSE_NO], [M.DATASOURCE], [M.MID_CHANNELCODE], [M.AGENT_CODE], [M.AGENT_NAME], [M.INSURED_NAME], [M.APPLICANT_NAME], [M.START_DATE], [M.END_DATE], [M.ISSUE_DATE], [M.SUBPREMIUM], [M.LICENSENO], [M.VEHICLECLAIMTYPE], [M.ADDVALUETAX], [M.AMOUNT_TYPE_I], [M.AMOUNT_TYPE_II], [M.AMOUNT_TYPE_III], [M.AMOUNT_TYPE_IV], [M.AMOUNT_TYPE_V], [M.AMOUNT_OVERALL], [M.AMOUNT_OVERALL_TOTAL], [M.AMOUNT_OVERALL_BRANCH], [M.AMOUNT_OVERALL_DEPTGRP]), filter([M.BRANCH_CODE = ?], [M.LINE = ?], [M.CHANNELCODE IN (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)], [M.INSURE_WAY IN (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)]),
access([M.LINE], [M.DEPTGRP_CODE], [M.BRANCH_CODE], [M.DEPT_CODE], [M.HANDLER_CODE], [M.PRODUCTGRP_CODE], [M.CHANNELCODE], [M.THE4S_CODE], [M.USETYPE], [M.INSURE_WAY], [M.POLICY_CHARGE_ID], [M.POLICY_NO], [M.ENDORSE_NO], [M.DATASOURCE], [M.MID_CHANNELCODE], [M.AGENT_CODE], [M.AGENT_NAME], [M.INSURED_NAME], [M.APPLICANT_NAME], [M.START_DATE], [M.END_DATE], [M.ISSUE_DATE], [M.SUBPREMIUM], [M.LICENSENO], [M.VEHICLECLAIMTYPE], [M.ADDVALUETAX], [M.AMOUNT_TYPE_I], [M.AMOUNT_TYPE_II], [M.AMOUNT_TYPE_III], [M.AMOUNT_TYPE_IV], [M.AMOUNT_TYPE_V], [M.AMOUNT_OVERALL], [M.AMOUNT_OVERALL_TOTAL], [M.AMOUNT_OVERALL_BRANCH], [M.AMOUNT_OVERALL_DEPTGRP]), partitions(p0),
limit(?), offset(nil)
21 - output([E.NAME]), filter(nil),
access([E.NAME]), partitions(p0)
22 - output([O1.CODE], [O1.PARENT_ID], [O1.NAME]), filter(nil),
access([O1.CODE], [O1.PARENT_ID], [O1.NAME]), partitions(p0)
23 - output([O2.CODE], [O2.PARENT_ID], [O2.NAME]), filter(nil),
access([O2.CODE], [O2.PARENT_ID], [O2.NAME]), partitions(p0)
24 - output([EC.AAAAAAAAAAA], [EC.ENTITY_NAME]), filter([EC.AAAAAAAAAAA = ?]),
access([EC.AAAAAAAAAAA], [EC.ENTITY_NAME]), partitions(p0)

可以看到改写完后,原来执行计划 SUBPLAN FILTER 已经变成了 HASH RIGHT OUTER JOIN,而执行时间也从原来的 3184s 变成了 10.91s,直接起飞。

总结:近两年感觉国产数据库市场份额越来越高了,笔者SQL优化的案例更多得也是从ORACLE、MySQL变成了OB、金仓数据库,建议大家还是要好好深入学习下国产数据库(特别是金仓数据库,国产之光),免得35岁被优化了找不到工作 。  

oceanbase 标量子查询等价改写(复杂)的更多相关文章

  1. 标量子查询SQL改写

    一网友说下面sql跑的好慢,让我看看 sql代码: select er, cid, pid, tbl, zs, sy, (select count(sr.mobile_tele_no) from tb ...

  2. 标量子查询调优SQL

    fxnjbmhkk4pp4 select /*+ leading (wb,sb,qw) */ 'blocker('||wb.holding_session||':'||sb.username||')- ...

  3. 标量子查询加聚合函数sql改写一

    标量子查询的语句: select /*+ GATHER_PLAN_STATISTICS dwtest */ empno, (select count(*) from DEPT1 b where b.i ...

  4. 优化有标量子查询的SQL

    数据库环境:SQL SERVER 2008R2 今天在数据库中抓出一条比较耗费资源的SQL,只返回904条数据,居然跑了40多分钟.SQL及对应的数据量如下图: SELECT saft04.cur_y ...

  5. Oracle sql优化之分析函数优化标量子查询

    待优化语句如下 select a.code as code, a.m_code as m_code,a.stktype as f_stype,a.e_year as e_year, b.sname a ...

  6. 标量子查询中有ROWNUM=1怎么改?

    碰到标量子查询中有ROWNUM=1怎么改? select to_date(o.postdate,'yyyymmdd'), (select cur.c_code from cur_tbl cur whe ...

  7. SQL Server的优化器会缓存标量子查询结果集吗

    在这篇博客"ORACLE当中自定义函数性优化浅析"中,我们介绍了通过标量子查询缓存来优化函数性能: 标量子查询缓存(scalar subquery caching)会通过缓存结果减 ...

  8. [20180626]函数与标量子查询14.txt

    [20180626]函数与标量子查询14.txt --//前面看http://www.cnblogs.com/kerrycode/p/9099507.html链接,里面提到: 通俗来将,当使用标量子查 ...

  9. SELECT列表中的标量子查询

    发现了一种表连接新的写法,以前还没有这样写过或者见别人写过.跟同学聊天他们公司却很多人这样写,看来真的要学学sql了 表 CREATE TABLE `t_book` ( `FId` ) NOT NUL ...

  10. WHERE 子句中的标量子查询

    标量子查询不仅可以用在SELECT 语句的列表中,它还可以用在WHERE 子句中,而且实际应用中子查询很多的时候都是用在WHERE子句中的. 先来看一个简单的例子,我们要检索喜欢“Story”的读者主 ...

随机推荐

  1. MyBatis(log4j)

    log4j介绍 Log4j是Apache的一个开源项目,通过使用Log4j,我们可以控制日志信息输送的目的地是控制台.文件.GUI组件,甚至是套接口服务器.NT的事件记录器.UNIX Syslog守护 ...

  2. Centos 8 时钟同步

    Centos 8 时钟同步使用的是 chrony 参考:https://www.cnblogs.com/my-show-time/p/14658895.html $ rpm -qa | grep ch ...

  3. SpringBoot 笔记

    SpringBoot 笔记 一.Spring Boot 入门 1.Spring Boot 简介 2.微服务 2014,martin fowler 微服务:架构风格(服务微化) 一个应用应该是一组小型服 ...

  4. WPF-封装自定义雷达图控件

    源码地址:https://gitee.com/LiuShuiRuoBing/code_blog 雷达图用于表示不同内容的占比关系,在项目中有广泛的应用,但是目前未曾有封装良好的雷达图控件,鉴于最近项目 ...

  5. java与es8实战之三:Java API Client有关的知识点串讲

    欢迎访问我的GitHub 这里分类和汇总了欣宸的全部原创(含配套源码):https://github.com/zq2599/blog_demos 本篇概览 本篇是<java与es8实战>系 ...

  6. Oracle主键自增列

    SQL Server创建主键自增列我们可以使用"ID INT IDENTITY(1,1) NOT NULL PRIMARY KEY"一步到位创建,而Oracle创建主键自增列和SQ ...

  7. 如何成功将 API 客户的 transformer 模型推理速度加快 100 倍

    Transformers 已成为世界各地数据科学家用以探索最先进 NLP 模型.构建新 NLP 模块的默认库.它拥有超过 5000 个预训练和微调的模型,支持 250 多种语言,任君取用.无论你使用哪 ...

  8. 探析ElasticSearch Kibana在测试工作中的实践应用

    一. 为什么使用ES Kibana 离线数据测试中最重要的就是数据验证,一部分需要测试es存储数据的正确性,另一部分就需要验证接口从es取值逻辑的正确性.而为了验证es取值逻辑的正确性,就需要用到Ki ...

  9. 「coci 2021-2022 #1」Logičari

    link. 断环后把断的边所连的两个点特殊标记,作为两个特殊点.这样就是一个树,树的做法很简单吧,把两个特殊点特殊处理带进状态即可. 具体一点就是,设 \(f(x,c_x,c_f,c_{rt_1},c ...

  10. Django框架——模板层

    文章目录 1 模板层 一 模版简介 二 模版语法之变量 views.py html文件 三 模版之过滤器 语法: default length filesizeformat date slice tr ...