数据库版本:OceanBase 3.2.3.3
一、问题描述
在进行一次 Oracle 迁移 OB 时,有张表在 Oracle 上不能关 row movement,因此无法使用 OMS 迁移数据,在割接窗口期前使用 dbcat 单独迁移表结构,窗口期内再导入数据的方式特殊处理该表。
这是张分区表,在 Oracle 上的主键约束不包含分区键,但是 OB 要求主键必须包含分区键,因此这种情况在迁移到 OB 时有两种处理方式:
- OMS 工具:迁移时会将主键转成 全局唯一索引 +NOT NULL 约束,等价 Oracle 的主键约束。表没有显示主键,但会有一个隐式主键(分区键+隐藏自增列);
- dbcat 工具:迁移时会把分区键加入到主键中,这是个本地索引。
这里最主要的区别是:Oracle 上的主键是全局索引,用 dbcat 迁移到 OB 时会变成本地索引,用 OMS 迁移则还是全局索引。然后以下 SQL 做 nested-loop join 时关联字段是主键字段,每次到被驱动表上使用主键查找,需要对所有分区执行,因此慢了。
注:OMS、dbcat 都是迁移工具,不用深究,只需理解为什么会有这种区别即可,下面会做解释。
select
*
from
(
SELECT
a.act_Id as actId,
a.data_Id as dataId,
...
from
T1 a,
T2 b
where
a.data_Id = b.data_Id
and a.cmp_Status not in ('08')
and a.crt_Dttm >= to_date('2023-09-15 04:37:49', 'YYYY-mm-dd hh24:mi:ss')
and a.crt_Dttm < to_date('2023-10-14 04:37:49', 'YYYY-mm-dd hh24:mi:ss')
...
order by
a.reserve_Begin_Dttm asc,
a.act_Limit_Date asc,
a.act_Id asc
)
where
rownum = ?(0x7e7d01e5c560)], [A.CRT_DTTM(0x7e7d01e55070) < ?(0x7e7d01e5fb10)])
10 - output([B.POLICY_PAY_ADDR(0x7e7d01e781c0)], [B.SALE_CHANNEL(0x7e7d01e7a620)], [B.POLICY_NO(0x7e7d01e7ac30)], [B.FREE_LOOK_PERIOD(0x7e7d01e7b240)], [B.HOLDER_SEX(0x7e7d01e7b850)], [B.ORGAN4_ID(0x7e7d01e7be60)], [B.CANVASSER_CODE(0x7e7d01e7d090)], [B.CANVASSER_NAME(0x7e7d01e7d6a0)], [B.POLICY_OPE_DATE(0x7e7d01e7dcb0)]), filter(nil),
access all, force partition granule.
11 - output([B.POLICY_PAY_ADDR(0x7e7d01e781c0)], [B.SALE_CHANNEL(0x7e7d01e7a620)], [B.POLICY_NO(0x7e7d01e7ac30)], [B.FREE_LOOK_PERIOD(0x7e7d01e7b240)], [B.HOLDER_SEX(0x7e7d01e7b850)], [B.ORGAN4_ID(0x7e7d01e7be60)], [B.CANVASSER_CODE(0x7e7d01e7d090)], [B.CANVASSER_NAME(0x7e7d01e7d6a0)], [B.POLICY_OPE_DATE(0x7e7d01e7dcb0)]), filter(nil),
access([B.POLICY_PAY_ADDR(0x7e7d01e781c0)], [B.SALE_CHANNEL(0x7e7d01e7a620)], [B.POLICY_NO(0x7e7d01e7ac30)], [B.FREE_LOOK_PERIOD(0x7e7d01e7b240)], [B.HOLDER_SEX(0x7e7d01e7b850)], [B.ORGAN4_ID(0x7e7d01e7be60)], [B.CANVASSER_CODE(0x7e7d01e7d090)], [B.CANVASSER_NAME(0x7e7d01e7d6a0)], [B.POLICY_OPE_DATE(0x7e7d01e7dcb0)]), partitions(p[0-129]),
is_index_back=false,
range_key([B.DATA_ID(0x7e7d01e57890)], [B.POLICY_VALID_DATE(0x7e7d01e56550)]), range(MIN ; MAX),
range_cond([? = B.DATA_ID(0x7e7d01e57890)(0x7e887f48c800)])
Used Hint:
-------------------------------------
/*+
*/
Outline Data:
-------------------------------------
/*+
BEGIN_OUTLINE_DATA
LEADING(@"SEL$2" ("LIFE.A"@"SEL$2" "LIFE.B"@"SEL$2" ))
USE_NL(@"SEL$2" ("LIFE.B"@"SEL$2" ))
PQ_DISTRIBUTE(@"SEL$2" ("LIFE.B"@"SEL$2" ) BC2HOST NONE)
NO_USE_NL_MATERIALIZATION(@"SEL$2" ("LIFE.B"@"SEL$2" ))
FULL(@"SEL$2" "LIFE.A"@"SEL$2")
FULL(@"SEL$2" "LIFE.B"@"SEL$2")
END_OUTLINE_DATA
*/
Plan Type:
-------------------------------------
DISTRIBUTED
Optimization Info:
-------------------------------------
A:table_rows:11907770, physical_range_rows:595388, logical_range_rows:595388, index_back_rows:0, output_rows:57, est_method:local_storage, optimization_method=cost_based, avaiable_index_name[IDX_LI_COUT_ACTIVITY_DATAID,IDX_LI_COUT_ACTIVIT_RESE,IDX_T_LI_COUT_ACTIVITY,IDX_T_LI_COUT_ACTIVITY_TEST2,T_LI_COUT_ACTIVITY], pruned_index_name[PK_T_LI_COUT_ACTIVITY,IDX_CUSTOMER_ID_CARD,IDX_LI_COUT_ACT_NEXTDTTM,IDX_LI_COUT_ACTIVITY_CALLCRT,IDX_LI_COUT_ACTIVITY_ASID,IDX_LI_COUT_ACTIVITY_BDATE,IDX_LI_COUT_ACTIVITY_CDT,IDX_LI_COUT_ACTIVITY_CPS,IDX_LI_COUT_ACTIVITY_ENDDATE,IDX_LI_COUT_ACTIVITY_LASTDTTM,IDX_LI_COUT_ACTIVITY_LDT,IDX_LI_COUT_ACTIVITY_LRT,IDX_LI_COUT_ACTIVITY_OWN,IDX_LI_COUT_ACT_FIRSTACTID,IDX_T_LI_COUT_ACTIVITY_SHUSHUI,IDX_GLO_CMP_TYPE_ID,IDX_GLO_ASSOC_CMP]
B:table_rows:114906166, physical_range_rows:6, logical_range_rows:6, index_back_rows:0, output_rows:6, est_method:local_storage, optimization_method=rule_based, heuristic_rule=unique_index_with_indexback
走全局唯一索引的执行计划:
=====================================================================
|ID|OPERATOR |NAME |EST. ROWS|COST |
---------------------------------------------------------------------
|0 |LIMIT | |10 |235743|
|1 | PX COORDINATOR MERGE SORT | |10 |235743|
|2 | EXCHANGE OUT DISTR |:EX10000 |10 |235694|
|3 | LIMIT | |10 |235694|
|4 | TOP-N SORT | |10 |235694|
|5 | PX PARTITION ITERATOR | |55 |235668|
|6 | NESTED-LOOP JOIN | |55 |235668|
|7 | TABLE SCAN |A |58 |234297|
|8 | TABLE LOOKUP |B |1 |23 |
|9 | DISTRIBUTED TABLE SCAN|B(UIDX_DATA_ID2)|1 |12 |
=====================================================================
Outputs & filters:
-------------------------------------
0 - output([A.ACT_ID(0x7f03a5ae63e0)], [A.DATA_ID(0x7f03a5adb940)], [A.CMP_STATUS(0x7f03a5adf170)], [A.CMP_TYPE_CD(0x7f03a5ade0a0)], [A.CMP_TYPE_ID(0x7f03a5ae7350)], [A.COUT_MODE(0x7f03a5ae7960)], [A.ASSOCIATE_ID(0x7f03a5ae7f70)], [A.ORGAN_ID(0x7f03a5ae8580)], [A.CUSTOMER_TYPE(0x7f03a5ae8b90)], [A.CUSTOMER_NAME(0x7f03a5ae91a0)], [A.RES_CODE(0x7f03a5ae97b0)], [A.CRT_DTTM(0x7f03a5ad9410)], [A.USER_GRP_ID(0x7f03a5aea0e0)], [A.USER_ID(0x7f03a5aea6f0)], [A.ACT_LIMIT_DATE(0x7f03a5aecd10)], [A.CALL_CRT_DTTM(0x7f03a5aed320)], [A.CONTACT_TEL1(0x7f03a5aed930)], [A.CONTACT_TEL2(0x7f03a5afbf50)], [B.POLICY_PAY_ADDR(0x7f03a5afc560)], [A.ORGAN3_ID(0x7f03a5afcb70)], [A.FAIL_COUT_NUM(0x7f03a5afd180)], [A.SYS_TYPE(0x7f03a5afd790)], [A.RESERVE_BEGIN_DTTM(0x7f03a5afdda0)], [A.RESERVE_END_DTTM(0x7f03a5afe3b0)], [B.SALE_CHANNEL(0x7f03a5afe9c0)], [B.POLICY_NO(0x7f03a5afefd0)], [B.FREE_LOOK_PERIOD(0x7f03a5aff5e0)], [B.HOLDER_SEX(0x7f03a5affbf0)], [B.ORGAN4_ID(0x7f03a5b00200)], [A.ASSIGN_DTTM(0x7f03a5b00810)], [A.HANDLER_AGENT_CODE(0x7f03a5b00e20)], [B.CANVASSER_CODE(0x7f03a5b01430)], [B.CANVASSER_NAME(0x7f03a5b01a40)], [B.POLICY_OPE_DATE(0x7f03a5b02050)], [A.APP_FLG(0x7f03a5b02660)], [A.INTER_FLG(0x7f03a5b02c70)]), filter(nil), limit(?), offset(nil)
1 - output([A.ACT_ID(0x7f03a5ae63e0)], [A.DATA_ID(0x7f03a5adb940)], [A.CMP_STATUS(0x7f03a5adf170)], [A.CMP_TYPE_CD(0x7f03a5ade0a0)], [A.CMP_TYPE_ID(0x7f03a5ae7350)], [A.COUT_MODE(0x7f03a5ae7960)], [A.ASSOCIATE_ID(0x7f03a5ae7f70)], [A.ORGAN_ID(0x7f03a5ae8580)], [A.CUSTOMER_TYPE(0x7f03a5ae8b90)], [A.CUSTOMER_NAME(0x7f03a5ae91a0)], [A.RES_CODE(0x7f03a5ae97b0)], [A.CRT_DTTM(0x7f03a5ad9410)], [A.USER_GRP_ID(0x7f03a5aea0e0)], [A.USER_ID(0x7f03a5aea6f0)], [A.ACT_LIMIT_DATE(0x7f03a5aecd10)], [A.CALL_CRT_DTTM(0x7f03a5aed320)], [A.CONTACT_TEL1(0x7f03a5aed930)], [A.CONTACT_TEL2(0x7f03a5afbf50)], [B.POLICY_PAY_ADDR(0x7f03a5afc560)], [A.ORGAN3_ID(0x7f03a5afcb70)], [A.FAIL_COUT_NUM(0x7f03a5afd180)], [A.SYS_TYPE(0x7f03a5afd790)], [A.RESERVE_BEGIN_DTTM(0x7f03a5afdda0)], [A.RESERVE_END_DTTM(0x7f03a5afe3b0)], [B.SALE_CHANNEL(0x7f03a5afe9c0)], [B.POLICY_NO(0x7f03a5afefd0)], [B.FREE_LOOK_PERIOD(0x7f03a5aff5e0)], [B.HOLDER_SEX(0x7f03a5affbf0)], [B.ORGAN4_ID(0x7f03a5b00200)], [A.ASSIGN_DTTM(0x7f03a5b00810)], [A.HANDLER_AGENT_CODE(0x7f03a5b00e20)], [B.CANVASSER_CODE(0x7f03a5b01430)], [B.CANVASSER_NAME(0x7f03a5b01a40)], [B.POLICY_OPE_DATE(0x7f03a5b02050)], [A.APP_FLG(0x7f03a5b02660)], [A.INTER_FLG(0x7f03a5b02c70)]), filter(nil), sort_keys([A.RESERVE_BEGIN_DTTM(0x7f03a5afdda0), ASC], [A.ACT_LIMIT_DATE(0x7f03a5aecd10), ASC], [A.ACT_ID(0x7f03a5ae63e0), ASC])
2 - output([A.ACT_ID(0x7f03a5ae63e0)], [A.DATA_ID(0x7f03a5adb940)], [A.CMP_STATUS(0x7f03a5adf170)], [A.CMP_TYPE_CD(0x7f03a5ade0a0)], [A.CMP_TYPE_ID(0x7f03a5ae7350)], [A.COUT_MODE(0x7f03a5ae7960)], [A.ASSOCIATE_ID(0x7f03a5ae7f70)], [A.ORGAN_ID(0x7f03a5ae8580)], [A.CUSTOMER_TYPE(0x7f03a5ae8b90)], [A.CUSTOMER_NAME(0x7f03a5ae91a0)], [A.RES_CODE(0x7f03a5ae97b0)], [A.CRT_DTTM(0x7f03a5ad9410)], [A.USER_GRP_ID(0x7f03a5aea0e0)], [A.USER_ID(0x7f03a5aea6f0)], [A.ACT_LIMIT_DATE(0x7f03a5aecd10)], [A.CALL_CRT_DTTM(0x7f03a5aed320)], [A.CONTACT_TEL1(0x7f03a5aed930)], [A.CONTACT_TEL2(0x7f03a5afbf50)], [B.POLICY_PAY_ADDR(0x7f03a5afc560)], [A.ORGAN3_ID(0x7f03a5afcb70)], [A.FAIL_COUT_NUM(0x7f03a5afd180)], [A.SYS_TYPE(0x7f03a5afd790)], [A.RESERVE_BEGIN_DTTM(0x7f03a5afdda0)], [A.RESERVE_END_DTTM(0x7f03a5afe3b0)], [B.SALE_CHANNEL(0x7f03a5afe9c0)], [B.POLICY_NO(0x7f03a5afefd0)], [B.FREE_LOOK_PERIOD(0x7f03a5aff5e0)], [B.HOLDER_SEX(0x7f03a5affbf0)], [B.ORGAN4_ID(0x7f03a5b00200)], [A.ASSIGN_DTTM(0x7f03a5b00810)], [A.HANDLER_AGENT_CODE(0x7f03a5b00e20)], [B.CANVASSER_CODE(0x7f03a5b01430)], [B.CANVASSER_NAME(0x7f03a5b01a40)], [B.POLICY_OPE_DATE(0x7f03a5b02050)], [A.APP_FLG(0x7f03a5b02660)], [A.INTER_FLG(0x7f03a5b02c70)]), filter(nil), dop=1
3 - output([A.ACT_ID(0x7f03a5ae63e0)], [A.DATA_ID(0x7f03a5adb940)], [A.CMP_STATUS(0x7f03a5adf170)], [A.CMP_TYPE_CD(0x7f03a5ade0a0)], [A.CMP_TYPE_ID(0x7f03a5ae7350)], [A.COUT_MODE(0x7f03a5ae7960)], [A.ASSOCIATE_ID(0x7f03a5ae7f70)], [A.ORGAN_ID(0x7f03a5ae8580)], [A.CUSTOMER_TYPE(0x7f03a5ae8b90)], [A.CUSTOMER_NAME(0x7f03a5ae91a0)], [A.RES_CODE(0x7f03a5ae97b0)], [A.CRT_DTTM(0x7f03a5ad9410)], [A.USER_GRP_ID(0x7f03a5aea0e0)], [A.USER_ID(0x7f03a5aea6f0)], [A.ACT_LIMIT_DATE(0x7f03a5aecd10)], [A.CALL_CRT_DTTM(0x7f03a5aed320)], [A.CONTACT_TEL1(0x7f03a5aed930)], [A.CONTACT_TEL2(0x7f03a5afbf50)], [B.POLICY_PAY_ADDR(0x7f03a5afc560)], [A.ORGAN3_ID(0x7f03a5afcb70)], [A.FAIL_COUT_NUM(0x7f03a5afd180)], [A.SYS_TYPE(0x7f03a5afd790)], [A.RESERVE_BEGIN_DTTM(0x7f03a5afdda0)], [A.RESERVE_END_DTTM(0x7f03a5afe3b0)], [B.SALE_CHANNEL(0x7f03a5afe9c0)], [B.POLICY_NO(0x7f03a5afefd0)], [B.FREE_LOOK_PERIOD(0x7f03a5aff5e0)], [B.HOLDER_SEX(0x7f03a5affbf0)], [B.ORGAN4_ID(0x7f03a5b00200)], [A.ASSIGN_DTTM(0x7f03a5b00810)], [A.HANDLER_AGENT_CODE(0x7f03a5b00e20)], [B.CANVASSER_CODE(0x7f03a5b01430)], [B.CANVASSER_NAME(0x7f03a5b01a40)], [B.POLICY_OPE_DATE(0x7f03a5b02050)], [A.APP_FLG(0x7f03a5b02660)], [A.INTER_FLG(0x7f03a5b02c70)]), filter(nil), limit(?), offset(nil)
4 - output([A.ACT_ID(0x7f03a5ae63e0)], [A.DATA_ID(0x7f03a5adb940)], [A.CMP_STATUS(0x7f03a5adf170)], [A.CMP_TYPE_CD(0x7f03a5ade0a0)], [A.CMP_TYPE_ID(0x7f03a5ae7350)], [A.COUT_MODE(0x7f03a5ae7960)], [A.ASSOCIATE_ID(0x7f03a5ae7f70)], [A.ORGAN_ID(0x7f03a5ae8580)], [A.CUSTOMER_TYPE(0x7f03a5ae8b90)], [A.CUSTOMER_NAME(0x7f03a5ae91a0)], [A.RES_CODE(0x7f03a5ae97b0)], [A.CRT_DTTM(0x7f03a5ad9410)], [A.USER_GRP_ID(0x7f03a5aea0e0)], [A.USER_ID(0x7f03a5aea6f0)], [A.ACT_LIMIT_DATE(0x7f03a5aecd10)], [A.CALL_CRT_DTTM(0x7f03a5aed320)], [A.CONTACT_TEL1(0x7f03a5aed930)], [A.CONTACT_TEL2(0x7f03a5afbf50)], [B.POLICY_PAY_ADDR(0x7f03a5afc560)], [A.ORGAN3_ID(0x7f03a5afcb70)], [A.FAIL_COUT_NUM(0x7f03a5afd180)], [A.SYS_TYPE(0x7f03a5afd790)], [A.RESERVE_BEGIN_DTTM(0x7f03a5afdda0)], [A.RESERVE_END_DTTM(0x7f03a5afe3b0)], [B.SALE_CHANNEL(0x7f03a5afe9c0)], [B.POLICY_NO(0x7f03a5afefd0)], [B.FREE_LOOK_PERIOD(0x7f03a5aff5e0)], [B.HOLDER_SEX(0x7f03a5affbf0)], [B.ORGAN4_ID(0x7f03a5b00200)], [A.ASSIGN_DTTM(0x7f03a5b00810)], [A.HANDLER_AGENT_CODE(0x7f03a5b00e20)], [B.CANVASSER_CODE(0x7f03a5b01430)], [B.CANVASSER_NAME(0x7f03a5b01a40)], [B.POLICY_OPE_DATE(0x7f03a5b02050)], [A.APP_FLG(0x7f03a5b02660)], [A.INTER_FLG(0x7f03a5b02c70)]), filter(nil), sort_keys([A.RESERVE_BEGIN_DTTM(0x7f03a5afdda0), ASC], [A.ACT_LIMIT_DATE(0x7f03a5aecd10), ASC], [A.ACT_ID(0x7f03a5ae63e0), ASC]), topn(?)
5 - output([A.ACT_ID(0x7f03a5ae63e0)], [A.DATA_ID(0x7f03a5adb940)], [A.CMP_STATUS(0x7f03a5adf170)], [A.CMP_TYPE_CD(0x7f03a5ade0a0)], [A.CMP_TYPE_ID(0x7f03a5ae7350)], [A.COUT_MODE(0x7f03a5ae7960)], [A.ASSOCIATE_ID(0x7f03a5ae7f70)], [A.ORGAN_ID(0x7f03a5ae8580)], [A.CUSTOMER_TYPE(0x7f03a5ae8b90)], [A.CUSTOMER_NAME(0x7f03a5ae91a0)], [A.RES_CODE(0x7f03a5ae97b0)], [A.CRT_DTTM(0x7f03a5ad9410)], [A.USER_GRP_ID(0x7f03a5aea0e0)], [A.USER_ID(0x7f03a5aea6f0)], [A.ACT_LIMIT_DATE(0x7f03a5aecd10)], [A.CALL_CRT_DTTM(0x7f03a5aed320)], [A.CONTACT_TEL1(0x7f03a5aed930)], [A.CONTACT_TEL2(0x7f03a5afbf50)], [B.POLICY_PAY_ADDR(0x7f03a5afc560)], [A.ORGAN3_ID(0x7f03a5afcb70)], [A.FAIL_COUT_NUM(0x7f03a5afd180)], [A.SYS_TYPE(0x7f03a5afd790)], [A.RESERVE_BEGIN_DTTM(0x7f03a5afdda0)], [A.RESERVE_END_DTTM(0x7f03a5afe3b0)], [B.SALE_CHANNEL(0x7f03a5afe9c0)], [B.POLICY_NO(0x7f03a5afefd0)], [B.FREE_LOOK_PERIOD(0x7f03a5aff5e0)], [B.HOLDER_SEX(0x7f03a5affbf0)], [B.ORGAN4_ID(0x7f03a5b00200)], [A.ASSIGN_DTTM(0x7f03a5b00810)], [A.HANDLER_AGENT_CODE(0x7f03a5b00e20)], [B.CANVASSER_CODE(0x7f03a5b01430)], [B.CANVASSER_NAME(0x7f03a5b01a40)], [B.POLICY_OPE_DATE(0x7f03a5b02050)], [A.APP_FLG(0x7f03a5b02660)], [A.INTER_FLG(0x7f03a5b02c70)]), filter(nil),
partition wise, force partition granule, asc.
6 - output([A.ACT_ID(0x7f03a5ae63e0)], [A.DATA_ID(0x7f03a5adb940)], [A.CMP_STATUS(0x7f03a5adf170)], [A.CMP_TYPE_CD(0x7f03a5ade0a0)], [A.CMP_TYPE_ID(0x7f03a5ae7350)], [A.COUT_MODE(0x7f03a5ae7960)], [A.ASSOCIATE_ID(0x7f03a5ae7f70)], [A.ORGAN_ID(0x7f03a5ae8580)], [A.CUSTOMER_TYPE(0x7f03a5ae8b90)], [A.CUSTOMER_NAME(0x7f03a5ae91a0)], [A.RES_CODE(0x7f03a5ae97b0)], [A.CRT_DTTM(0x7f03a5ad9410)], [A.USER_GRP_ID(0x7f03a5aea0e0)], [A.USER_ID(0x7f03a5aea6f0)], [A.ACT_LIMIT_DATE(0x7f03a5aecd10)], [A.CALL_CRT_DTTM(0x7f03a5aed320)], [A.CONTACT_TEL1(0x7f03a5aed930)], [A.CONTACT_TEL2(0x7f03a5afbf50)], [B.POLICY_PAY_ADDR(0x7f03a5afc560)], [A.ORGAN3_ID(0x7f03a5afcb70)], [A.FAIL_COUT_NUM(0x7f03a5afd180)], [A.SYS_TYPE(0x7f03a5afd790)], [A.RESERVE_BEGIN_DTTM(0x7f03a5afdda0)], [A.RESERVE_END_DTTM(0x7f03a5afe3b0)], [B.SALE_CHANNEL(0x7f03a5afe9c0)], [B.POLICY_NO(0x7f03a5afefd0)], [B.FREE_LOOK_PERIOD(0x7f03a5aff5e0)], [B.HOLDER_SEX(0x7f03a5affbf0)], [B.ORGAN4_ID(0x7f03a5b00200)], [A.ASSIGN_DTTM(0x7f03a5b00810)], [A.HANDLER_AGENT_CODE(0x7f03a5b00e20)], [B.CANVASSER_CODE(0x7f03a5b01430)], [B.CANVASSER_NAME(0x7f03a5b01a40)], [B.POLICY_OPE_DATE(0x7f03a5b02050)], [A.APP_FLG(0x7f03a5b02660)], [A.INTER_FLG(0x7f03a5b02c70)]), filter(nil),
conds(nil), nl_params_([A.DATA_ID(0x7f03a5adb940)]), batch_join=false
7 - output([A.CRT_DTTM(0x7f03a5ad9410)], [A.DATA_ID(0x7f03a5adb940)], [A.CMP_TYPE_CD(0x7f03a5ade0a0)], [A.CMP_STATUS(0x7f03a5adf170)], [A.ACT_ID(0x7f03a5ae63e0)], [A.CMP_TYPE_ID(0x7f03a5ae7350)], [A.COUT_MODE(0x7f03a5ae7960)], [A.ASSOCIATE_ID(0x7f03a5ae7f70)], [A.ORGAN_ID(0x7f03a5ae8580)], [A.CUSTOMER_TYPE(0x7f03a5ae8b90)], [A.CUSTOMER_NAME(0x7f03a5ae91a0)], [A.RES_CODE(0x7f03a5ae97b0)], [A.USER_GRP_ID(0x7f03a5aea0e0)], [A.USER_ID(0x7f03a5aea6f0)], [A.ACT_LIMIT_DATE(0x7f03a5aecd10)], [A.CALL_CRT_DTTM(0x7f03a5aed320)], [A.CONTACT_TEL1(0x7f03a5aed930)], [A.CONTACT_TEL2(0x7f03a5afbf50)], [A.ORGAN3_ID(0x7f03a5afcb70)], [A.FAIL_COUT_NUM(0x7f03a5afd180)], [A.SYS_TYPE(0x7f03a5afd790)], [A.RESERVE_BEGIN_DTTM(0x7f03a5afdda0)], [A.RESERVE_END_DTTM(0x7f03a5afe3b0)], [A.ASSIGN_DTTM(0x7f03a5b00810)], [A.HANDLER_AGENT_CODE(0x7f03a5b00e20)], [A.APP_FLG(0x7f03a5b02660)], [A.INTER_FLG(0x7f03a5b02c70)]), filter([A.CMP_TYPE_CD(0x7f03a5ade0a0) = ?(0x7f03a5add980)], [(T_OP_IS, A.POOL_STATUS(0x7f03a5adcfb0), NULL, 0)(0x7f03a5adc5e0)], [A.CMP_STATUS(0x7f03a5adf170) != ?(0x7f03a5ade4b0)]),
access([A.CRT_DTTM(0x7f03a5ad9410)], [A.DATA_ID(0x7f03a5adb940)], [A.POOL_STATUS(0x7f03a5adcfb0)], [A.CMP_TYPE_CD(0x7f03a5ade0a0)], [A.CMP_STATUS(0x7f03a5adf170)], [A.ACT_ID(0x7f03a5ae63e0)], [A.CMP_TYPE_ID(0x7f03a5ae7350)], [A.COUT_MODE(0x7f03a5ae7960)], [A.ASSOCIATE_ID(0x7f03a5ae7f70)], [A.ORGAN_ID(0x7f03a5ae8580)], [A.CUSTOMER_TYPE(0x7f03a5ae8b90)], [A.CUSTOMER_NAME(0x7f03a5ae91a0)], [A.RES_CODE(0x7f03a5ae97b0)], [A.USER_GRP_ID(0x7f03a5aea0e0)], [A.USER_ID(0x7f03a5aea6f0)], [A.ACT_LIMIT_DATE(0x7f03a5aecd10)], [A.CALL_CRT_DTTM(0x7f03a5aed320)], [A.CONTACT_TEL1(0x7f03a5aed930)], [A.CONTACT_TEL2(0x7f03a5afbf50)], [A.ORGAN3_ID(0x7f03a5afcb70)], [A.FAIL_COUT_NUM(0x7f03a5afd180)], [A.SYS_TYPE(0x7f03a5afd790)], [A.RESERVE_BEGIN_DTTM(0x7f03a5afdda0)], [A.RESERVE_END_DTTM(0x7f03a5afe3b0)], [A.ASSIGN_DTTM(0x7f03a5b00810)], [A.HANDLER_AGENT_CODE(0x7f03a5b00e20)], [A.APP_FLG(0x7f03a5b02660)], [A.INTER_FLG(0x7f03a5b02c70)]), partitions(p[116-117]),
is_index_back=false, filter_before_indexback[false,false,false],
range_key([A.CRT_DTTM(0x7f03a5ad9410)], [A.__pk_increment(0x7f03a5bfd970)]), range(2023-09-15 04:37:49,MIN ; 2023-10-14 04:37:49,MIN),
range_cond([A.CRT_DTTM(0x7f03a5ad9410) >= ?(0x7f03a5ae0900)], [A.CRT_DTTM(0x7f03a5ad9410) < ?(0x7f03a5ae3eb0)])
8 - output([B.POLICY_PAY_ADDR(0x7f03a5afc560)], [B.SALE_CHANNEL(0x7f03a5afe9c0)], [B.POLICY_NO(0x7f03a5afefd0)], [B.FREE_LOOK_PERIOD(0x7f03a5aff5e0)], [B.HOLDER_SEX(0x7f03a5affbf0)], [B.ORGAN4_ID(0x7f03a5b00200)], [B.CANVASSER_CODE(0x7f03a5b01430)], [B.CANVASSER_NAME(0x7f03a5b01a40)], [B.POLICY_OPE_DATE(0x7f03a5b02050)]), filter(nil),
partitions(p[0-129])
9 - output([B.DATA_ID(0x7f03a5adbc30)], [B.POLICY_VALID_DATE(0x7f03a5ada8f0)]), filter(nil),
access([B.DATA_ID(0x7f03a5adbc30)], [B.POLICY_VALID_DATE(0x7f03a5ada8f0)]), partitions(p0),
is_index_back=false,
range_key([B.DATA_ID(0x7f03a5adbc30)], [B.shadow_pk_0(0x7e791da35600)], [B.shadow_pk_1(0x7e791da358f0)]), range(MIN ; MAX),
range_cond([? = B.DATA_ID(0x7f03a5adbc30)(0x7e791da4df70)])
Used Hint:
-------------------------------------
/*+
INDEX(@"SEL$2" "LIFE.B"@"SEL$2" "UIDX_DATA_ID2")
*/
Outline Data:
-------------------------------------
/*+
BEGIN_OUTLINE_DATA
LEADING(@"SEL$2" ("LIFE.A"@"SEL$2" "LIFE.B"@"SEL$2" ))
USE_NL(@"SEL$2" ("LIFE.B"@"SEL$2" ))
PQ_DISTRIBUTE(@"SEL$2" ("LIFE.B"@"SEL$2" ) NONE NONE)
NO_USE_NL_MATERIALIZATION(@"SEL$2" ("LIFE.B"@"SEL$2" ))
FULL(@"SEL$2" "LIFE.A"@"SEL$2")
INDEX(@"SEL$2" "LIFE.B"@"SEL$2" "UIDX_DATA_ID2")
END_OUTLINE_DATA
*/
Plan Type:
-------------------------------------
DISTRIBUTED
Optimization Info:
-------------------------------------
A:table_rows:11907770, physical_range_rows:595388, logical_range_rows:595388, index_back_rows:0, output_rows:57, est_method:local_storage, optimization_method=cost_based, avaiable_index_name[IDX_LI_COUT_ACTIVITY_DATAID,IDX_LI_COUT_ACTIVIT_RESE,IDX_T_LI_COUT_ACTIVITY,IDX_T_LI_COUT_ACTIVITY_TEST2,T_LI_COUT_ACTIVITY], pruned_index_name[PK_T_LI_COUT_ACTIVITY,IDX_CUSTOMER_ID_CARD,IDX_LI_COUT_ACT_NEXTDTTM,IDX_LI_COUT_ACTIVITY_CALLCRT,IDX_LI_COUT_ACTIVITY_ASID,IDX_LI_COUT_ACTIVITY_BDATE,IDX_LI_COUT_ACTIVITY_CDT,IDX_LI_COUT_ACTIVITY_CPS,IDX_LI_COUT_ACTIVITY_ENDDATE,IDX_LI_COUT_ACTIVITY_LASTDTTM,IDX_LI_COUT_ACTIVITY_LDT,IDX_LI_COUT_ACTIVITY_LRT,IDX_LI_COUT_ACTIVITY_OWN,IDX_LI_COUT_ACT_FIRSTACTID,IDX_T_LI_COUT_ACTIVITY_SHUSHUI,IDX_GLO_CMP_TYPE_ID,IDX_GLO_ASSOC_CMP]
B:table_rows:114906166, physical_range_rows:1, logical_range_rows:1, index_back_rows:1, output_rows:1, est_method:local_storage, optimization_method=rule_based, heuristic_rule=unique_index_with_indexback
2. 拆解 SQL
从执行计划来看,都是 A nested-loop join B。驱动表 A 表都是走主键,不用管,被驱动表 B 走主键和走全局唯一索引是有区别的,构造一个简单的查询测试即可看出对比:
- 默认走主键,要扫 130 个分区,耗时 7ms
- 加 hint /*+ index(b UIDX_DATA_ID2) */,走全局唯一索引,耗时 700us
select
*
from
T2 b
where
data_id = 13260601;
走主键的执行计划中,最关键的信息是 partitions(p[0-129]),要到所有分区上进行查找:
====================================================
|ID|OPERATOR |NAME |EST. ROWS|COST|
----------------------------------------------------
|0 |PX COORDINATOR | |1 |58 |
|1 | EXCHANGE OUT DISTR |:EX10000|1 |46 |
|2 | PX PARTITION ITERATOR| |1 |46 |
|3 | TABLE SCAN |B |1 |46 |
====================================================
Outputs & filters:
-------------------------------------
0 - output([INTERNAL_FUNCTION(B.DATA_ID(0x7e6e391fc690), B.BATCH_ID(0x7e6e391fca80), B.CMP_TYPE_ID(0x7e6e391fcd70), B.ORGAN_ID(0x7e6e391fd060), B.ORGAN3_ID(0x7e6e391fd350), B.POLICY_NO(0x7e6e391fd640), B.CLASS_CODE(0x7e6e391fd930), B.POLICY_ATTACH_FLG(0x7e6e391fdc20), B.POLICY_STATUS(0x7e6e391fdf10), B.POLICY_OPE_DATE(0x7e6e391fe200), B.POLICY_PAY_DATE(0x7e6e391fe4f0), B.POLICY_PREMIUM(0x7e6e391fe7e0), B.POLICY_PAYMETHOD(0x7e6e391fead0), B.POLICY_PAYYEARS(0x7e6e391fedc0), B.POLICY_PAY_ADDR(0x7e6e391ff0b0), B.POLICY_POSTCODE(0x7e6e391ff3a0), B.PAYMENT_TEL_AREA(0x7e6e392016a0), B.POLICY_PAYMENT_TEL(0x7e6e39201990), B.CUSTOMER_ID(0x7e6e39201c80), B.HOLDER_IDCARD(0x7e6e39201f70), B.HOLDER_NAME(0x7e6e39202260), B.HOLDER_SEX(0x7e6e39202550), B.WORK_TEL_AREA(0x7e6e39202840), B.HOLDER_WORK_TEL(0x7e6e39202b30), B.FAMILY_TEL_AREA(0x7e6e39202e20), B.HOLDER_FAMILY_TEL(0x7e6e39203110), B.MOBILE_TEL_AREA(0x7e6e39203400), B.HOLDER_MOBILE_NO(0x7e6e392036f0), B.RECOGNIZEE_IDCARD(0x7e6e392039e0), B.RECOGNIZEE_NAME(0x7e6e39203cd0), B.RECOGNIZEE_GENDER(0x7e6e39203fc0), B.RECOGNIZEE_AGE(0x7e6e392042b0), B.HOLDER_REC_REL(0x7e6e392045a0), B.POLICY_APPDATE(0x7e6e39204890), B.CANVASSER_CODE(0x7e6e39204b80), B.CANVASSER_NAME(0x7e6e39204e70), B.CANVASSER_TEL(0x7e6e39205160), B.POLICY_VALID_DATE(0x7e6e391fb6b0), B.SALE_CHANNEL(0x7e6e39205450), B.BANK_FLG(0x7e6e39205740), B.REC_DATE(0x7e6e39205a30), B.REC_INPUT_DTTM(0x7e6e39205d20), B.SET_CODE(0x7e6e39206010), B.ACCO_NO(0x7e6e39206300), B.BANK_NAME(0x7e6e392065f0), B.HOLDER_BIRTH_DATE(0x7e6e392068e0), B.CUSTOMER_TYPE(0x7e6e39206bd0), B.OWNER_SOURCE_ID(0x7e6e39206ec0), B.INSURED_SOURCE_ID(0x7e6e392071b0), B.BUSIMAN_FLG(0x7e6e392074a0), B.OPE_END_DATE(0x7e6e39207790), B.SALE_TYPE(0x7e6e39207a80), B.OPERATING_AGENCIES(0x7e6e39207d70), B.SMS_REC_INPUT_DTTM(0x7e6e39208060), B.PAYMENT_STANDARD(0x7e6e39208350), B.PREMIUM_STANDARD(0x7e6e39208640), B.POLICY_PIECES(0x7e6e39208930), B.DIGITAL_FLG(0x7e6e39208c20), B.INSURE_METHOD(0x7e6e39208f10), B.SOURCE_SYSTEM_FLG(0x7e6e39209200), B.HOLDER_IDCARD2(0x7e6e392094f0), B.ACK_TYPE(0x7e6e392097e0), B.CHANNEL_CODE(0x7e6e39209ad0), B.ACTIVITY_CODE(0x7e6e39209dc0), B.GENJOB_FLG(0x7e6e3920a0b0), B.HOLDER_AGE(0x7e6e3920a3a0), B.ORGAN4_ID(0x7e6e3920a690), B.HESITATE_DAY(0x7e6e3920a980), B.LOWEST_RATE(0x7e6e3920ac70), B.CRT_USER_ID(0x7e6e3920af60), B.CRT_DTTM(0x7e6e3920b250), B.LASTUPT_USER_ID(0x7e6e3920b540), B.LASTUPT_DTTM(0x7e6e3920b830), B.ENABLE_FLG(0x7e6e3920bb20), B.ACC_CREATE_FLG(0x7e6e3920be10), B.FREE_LOOK_PERIOD(0x7e6e3920c100), B.NEWFLAG(0x7e6e3920c3f0), B.PROTECT_FLG(0x7e6e3920c6e0), B.DEPTNAME(0x7e6e3920c9d0), B.SUB_SALE_TYPE(0x7e6e3920ccc0), B.DOUBLE_RECORD(0x7e6e3920cfb0), B.BQ_OPTION(0x7e6e3920d2a0), B.HOLDER_IDCARD_TYPE(0x7e6e3920d590), B.HOLDER_OTHER_IDCARD(0x7e6e3920d880), B.RECOGNIZEE_IDCARD_TYPE(0x7e6e3920db70), B.RECOGNIZEE_OTHER_IDCARD(0x7e6e3920de60), B.SUBAMT(0x7e6e3920e150), B.RENEW_FLG(0x7e6e3920e440), B.PRDCT_TYPE(0x7e6e3920e730), B.VIDEO_FLG(0x7e6e3920ea20), B.YB_BANK_NAME(0x7e6e3920ed10), B.MULTI_RECOGNIZEE_AGE(0x7e6e3920f000))(0x7e6e3932de70)]), filter(nil)
1 - output([INTERNAL_FUNCTION(B.DATA_ID(0x7e6e391fc690), B.BATCH_ID(0x7e6e391fca80), B.CMP_TYPE_ID(0x7e6e391fcd70), B.ORGAN_ID(0x7e6e391fd060), B.ORGAN3_ID(0x7e6e391fd350), B.POLICY_NO(0x7e6e391fd640), B.CLASS_CODE(0x7e6e391fd930), B.POLICY_ATTACH_FLG(0x7e6e391fdc20), B.POLICY_STATUS(0x7e6e391fdf10), B.POLICY_OPE_DATE(0x7e6e391fe200), B.POLICY_PAY_DATE(0x7e6e391fe4f0), B.POLICY_PREMIUM(0x7e6e391fe7e0), B.POLICY_PAYMETHOD(0x7e6e391fead0), B.POLICY_PAYYEARS(0x7e6e391fedc0), B.POLICY_PAY_ADDR(0x7e6e391ff0b0), B.POLICY_POSTCODE(0x7e6e391ff3a0), B.PAYMENT_TEL_AREA(0x7e6e392016a0), B.POLICY_PAYMENT_TEL(0x7e6e39201990), B.CUSTOMER_ID(0x7e6e39201c80), B.HOLDER_IDCARD(0x7e6e39201f70), B.HOLDER_NAME(0x7e6e39202260), B.HOLDER_SEX(0x7e6e39202550), B.WORK_TEL_AREA(0x7e6e39202840), B.HOLDER_WORK_TEL(0x7e6e39202b30), B.FAMILY_TEL_AREA(0x7e6e39202e20), B.HOLDER_FAMILY_TEL(0x7e6e39203110), B.MOBILE_TEL_AREA(0x7e6e39203400), B.HOLDER_MOBILE_NO(0x7e6e392036f0), B.RECOGNIZEE_IDCARD(0x7e6e392039e0), B.RECOGNIZEE_NAME(0x7e6e39203cd0), B.RECOGNIZEE_GENDER(0x7e6e39203fc0), B.RECOGNIZEE_AGE(0x7e6e392042b0), B.HOLDER_REC_REL(0x7e6e392045a0), B.POLICY_APPDATE(0x7e6e39204890), B.CANVASSER_CODE(0x7e6e39204b80), B.CANVASSER_NAME(0x7e6e39204e70), B.CANVASSER_TEL(0x7e6e39205160), B.POLICY_VALID_DATE(0x7e6e391fb6b0), B.SALE_CHANNEL(0x7e6e39205450), B.BANK_FLG(0x7e6e39205740), B.REC_DATE(0x7e6e39205a30), B.REC_INPUT_DTTM(0x7e6e39205d20), B.SET_CODE(0x7e6e39206010), B.ACCO_NO(0x7e6e39206300), B.BANK_NAME(0x7e6e392065f0), B.HOLDER_BIRTH_DATE(0x7e6e392068e0), B.CUSTOMER_TYPE(0x7e6e39206bd0), B.OWNER_SOURCE_ID(0x7e6e39206ec0), B.INSURED_SOURCE_ID(0x7e6e392071b0), B.BUSIMAN_FLG(0x7e6e392074a0), B.OPE_END_DATE(0x7e6e39207790), B.SALE_TYPE(0x7e6e39207a80), B.OPERATING_AGENCIES(0x7e6e39207d70), B.SMS_REC_INPUT_DTTM(0x7e6e39208060), B.PAYMENT_STANDARD(0x7e6e39208350), B.PREMIUM_STANDARD(0x7e6e39208640), B.POLICY_PIECES(0x7e6e39208930), B.DIGITAL_FLG(0x7e6e39208c20), B.INSURE_METHOD(0x7e6e39208f10), B.SOURCE_SYSTEM_FLG(0x7e6e39209200), B.HOLDER_IDCARD2(0x7e6e392094f0), B.ACK_TYPE(0x7e6e392097e0), B.CHANNEL_CODE(0x7e6e39209ad0), B.ACTIVITY_CODE(0x7e6e39209dc0), B.GENJOB_FLG(0x7e6e3920a0b0), B.HOLDER_AGE(0x7e6e3920a3a0), B.ORGAN4_ID(0x7e6e3920a690), B.HESITATE_DAY(0x7e6e3920a980), B.LOWEST_RATE(0x7e6e3920ac70), B.CRT_USER_ID(0x7e6e3920af60), B.CRT_DTTM(0x7e6e3920b250), B.LASTUPT_USER_ID(0x7e6e3920b540), B.LASTUPT_DTTM(0x7e6e3920b830), B.ENABLE_FLG(0x7e6e3920bb20), B.ACC_CREATE_FLG(0x7e6e3920be10), B.FREE_LOOK_PERIOD(0x7e6e3920c100), B.NEWFLAG(0x7e6e3920c3f0), B.PROTECT_FLG(0x7e6e3920c6e0), B.DEPTNAME(0x7e6e3920c9d0), B.SUB_SALE_TYPE(0x7e6e3920ccc0), B.DOUBLE_RECORD(0x7e6e3920cfb0), B.BQ_OPTION(0x7e6e3920d2a0), B.HOLDER_IDCARD_TYPE(0x7e6e3920d590), B.HOLDER_OTHER_IDCARD(0x7e6e3920d880), B.RECOGNIZEE_IDCARD_TYPE(0x7e6e3920db70), B.RECOGNIZEE_OTHER_IDCARD(0x7e6e3920de60), B.SUBAMT(0x7e6e3920e150), B.RENEW_FLG(0x7e6e3920e440), B.PRDCT_TYPE(0x7e6e3920e730), B.VIDEO_FLG(0x7e6e3920ea20), B.YB_BANK_NAME(0x7e6e3920ed10), B.MULTI_RECOGNIZEE_AGE(0x7e6e3920f000))(0x7e6e3932de70)]), filter(nil), dop=1
2 - output([B.POLICY_VALID_DATE(0x7e6e391fb6b0)], [B.DATA_ID(0x7e6e391fc690)], [B.BATCH_ID(0x7e6e391fca80)], [B.CMP_TYPE_ID(0x7e6e391fcd70)], [B.ORGAN_ID(0x7e6e391fd060)], [B.ORGAN3_ID(0x7e6e391fd350)], [B.POLICY_NO(0x7e6e391fd640)], [B.CLASS_CODE(0x7e6e391fd930)], [B.POLICY_ATTACH_FLG(0x7e6e391fdc20)], [B.POLICY_STATUS(0x7e6e391fdf10)], [B.POLICY_OPE_DATE(0x7e6e391fe200)], [B.POLICY_PAY_DATE(0x7e6e391fe4f0)], [B.POLICY_PREMIUM(0x7e6e391fe7e0)], [B.POLICY_PAYMETHOD(0x7e6e391fead0)], [B.POLICY_PAYYEARS(0x7e6e391fedc0)], [B.POLICY_PAY_ADDR(0x7e6e391ff0b0)], [B.POLICY_POSTCODE(0x7e6e391ff3a0)], [B.PAYMENT_TEL_AREA(0x7e6e392016a0)], [B.POLICY_PAYMENT_TEL(0x7e6e39201990)], [B.CUSTOMER_ID(0x7e6e39201c80)], [B.HOLDER_IDCARD(0x7e6e39201f70)], [B.HOLDER_NAME(0x7e6e39202260)], [B.HOLDER_SEX(0x7e6e39202550)], [B.WORK_TEL_AREA(0x7e6e39202840)], [B.HOLDER_WORK_TEL(0x7e6e39202b30)], [B.FAMILY_TEL_AREA(0x7e6e39202e20)], [B.HOLDER_FAMILY_TEL(0x7e6e39203110)], [B.MOBILE_TEL_AREA(0x7e6e39203400)], [B.HOLDER_MOBILE_NO(0x7e6e392036f0)], [B.RECOGNIZEE_IDCARD(0x7e6e392039e0)], [B.RECOGNIZEE_NAME(0x7e6e39203cd0)], [B.RECOGNIZEE_GENDER(0x7e6e39203fc0)], [B.RECOGNIZEE_AGE(0x7e6e392042b0)], [B.HOLDER_REC_REL(0x7e6e392045a0)], [B.POLICY_APPDATE(0x7e6e39204890)], [B.CANVASSER_CODE(0x7e6e39204b80)], [B.CANVASSER_NAME(0x7e6e39204e70)], [B.CANVASSER_TEL(0x7e6e39205160)], [B.SALE_CHANNEL(0x7e6e39205450)], [B.BANK_FLG(0x7e6e39205740)], [B.REC_DATE(0x7e6e39205a30)], [B.REC_INPUT_DTTM(0x7e6e39205d20)], [B.SET_CODE(0x7e6e39206010)], [B.ACCO_NO(0x7e6e39206300)], [B.BANK_NAME(0x7e6e392065f0)], [B.HOLDER_BIRTH_DATE(0x7e6e392068e0)], [B.CUSTOMER_TYPE(0x7e6e39206bd0)], [B.OWNER_SOURCE_ID(0x7e6e39206ec0)], [B.INSURED_SOURCE_ID(0x7e6e392071b0)], [B.BUSIMAN_FLG(0x7e6e392074a0)], [B.OPE_END_DATE(0x7e6e39207790)], [B.SALE_TYPE(0x7e6e39207a80)], [B.OPERATING_AGENCIES(0x7e6e39207d70)], [B.SMS_REC_INPUT_DTTM(0x7e6e39208060)], [B.PAYMENT_STANDARD(0x7e6e39208350)], [B.PREMIUM_STANDARD(0x7e6e39208640)], [B.POLICY_PIECES(0x7e6e39208930)], [B.DIGITAL_FLG(0x7e6e39208c20)], [B.INSURE_METHOD(0x7e6e39208f10)], [B.SOURCE_SYSTEM_FLG(0x7e6e39209200)], [B.HOLDER_IDCARD2(0x7e6e392094f0)], [B.ACK_TYPE(0x7e6e392097e0)], [B.CHANNEL_CODE(0x7e6e39209ad0)], [B.ACTIVITY_CODE(0x7e6e39209dc0)], [B.GENJOB_FLG(0x7e6e3920a0b0)], [B.HOLDER_AGE(0x7e6e3920a3a0)], [B.ORGAN4_ID(0x7e6e3920a690)], [B.HESITATE_DAY(0x7e6e3920a980)], [B.LOWEST_RATE(0x7e6e3920ac70)], [B.CRT_USER_ID(0x7e6e3920af60)], [B.CRT_DTTM(0x7e6e3920b250)], [B.LASTUPT_USER_ID(0x7e6e3920b540)], [B.LASTUPT_DTTM(0x7e6e3920b830)], [B.ENABLE_FLG(0x7e6e3920bb20)], [B.ACC_CREATE_FLG(0x7e6e3920be10)], [B.FREE_LOOK_PERIOD(0x7e6e3920c100)], [B.NEWFLAG(0x7e6e3920c3f0)], [B.PROTECT_FLG(0x7e6e3920c6e0)], [B.DEPTNAME(0x7e6e3920c9d0)], [B.SUB_SALE_TYPE(0x7e6e3920ccc0)], [B.DOUBLE_RECORD(0x7e6e3920cfb0)], [B.BQ_OPTION(0x7e6e3920d2a0)], [B.HOLDER_IDCARD_TYPE(0x7e6e3920d590)], [B.HOLDER_OTHER_IDCARD(0x7e6e3920d880)], [B.RECOGNIZEE_IDCARD_TYPE(0x7e6e3920db70)], [B.RECOGNIZEE_OTHER_IDCARD(0x7e6e3920de60)], [B.SUBAMT(0x7e6e3920e150)], [B.RENEW_FLG(0x7e6e3920e440)], [B.PRDCT_TYPE(0x7e6e3920e730)], [B.VIDEO_FLG(0x7e6e3920ea20)], [B.YB_BANK_NAME(0x7e6e3920ed10)], [B.MULTI_RECOGNIZEE_AGE(0x7e6e3920f000)]), filter(nil),
force partition granule, asc.
3 - output([B.POLICY_VALID_DATE(0x7e6e391fb6b0)], [B.DATA_ID(0x7e6e391fc690)], [B.BATCH_ID(0x7e6e391fca80)], [B.CMP_TYPE_ID(0x7e6e391fcd70)], [B.ORGAN_ID(0x7e6e391fd060)], [B.ORGAN3_ID(0x7e6e391fd350)], [B.POLICY_NO(0x7e6e391fd640)], [B.CLASS_CODE(0x7e6e391fd930)], [B.POLICY_ATTACH_FLG(0x7e6e391fdc20)], [B.POLICY_STATUS(0x7e6e391fdf10)], [B.POLICY_OPE_DATE(0x7e6e391fe200)], [B.POLICY_PAY_DATE(0x7e6e391fe4f0)], [B.POLICY_PREMIUM(0x7e6e391fe7e0)], [B.POLICY_PAYMETHOD(0x7e6e391fead0)], [B.POLICY_PAYYEARS(0x7e6e391fedc0)], [B.POLICY_PAY_ADDR(0x7e6e391ff0b0)], [B.POLICY_POSTCODE(0x7e6e391ff3a0)], [B.PAYMENT_TEL_AREA(0x7e6e392016a0)], [B.POLICY_PAYMENT_TEL(0x7e6e39201990)], [B.CUSTOMER_ID(0x7e6e39201c80)], [B.HOLDER_IDCARD(0x7e6e39201f70)], [B.HOLDER_NAME(0x7e6e39202260)], [B.HOLDER_SEX(0x7e6e39202550)], [B.WORK_TEL_AREA(0x7e6e39202840)], [B.HOLDER_WORK_TEL(0x7e6e39202b30)], [B.FAMILY_TEL_AREA(0x7e6e39202e20)], [B.HOLDER_FAMILY_TEL(0x7e6e39203110)], [B.MOBILE_TEL_AREA(0x7e6e39203400)], [B.HOLDER_MOBILE_NO(0x7e6e392036f0)], [B.RECOGNIZEE_IDCARD(0x7e6e392039e0)], [B.RECOGNIZEE_NAME(0x7e6e39203cd0)], [B.RECOGNIZEE_GENDER(0x7e6e39203fc0)], [B.RECOGNIZEE_AGE(0x7e6e392042b0)], [B.HOLDER_REC_REL(0x7e6e392045a0)], [B.POLICY_APPDATE(0x7e6e39204890)], [B.CANVASSER_CODE(0x7e6e39204b80)], [B.CANVASSER_NAME(0x7e6e39204e70)], [B.CANVASSER_TEL(0x7e6e39205160)], [B.SALE_CHANNEL(0x7e6e39205450)], [B.BANK_FLG(0x7e6e39205740)], [B.REC_DATE(0x7e6e39205a30)], [B.REC_INPUT_DTTM(0x7e6e39205d20)], [B.SET_CODE(0x7e6e39206010)], [B.ACCO_NO(0x7e6e39206300)], [B.BANK_NAME(0x7e6e392065f0)], [B.HOLDER_BIRTH_DATE(0x7e6e392068e0)], [B.CUSTOMER_TYPE(0x7e6e39206bd0)], [B.OWNER_SOURCE_ID(0x7e6e39206ec0)], [B.INSURED_SOURCE_ID(0x7e6e392071b0)], [B.BUSIMAN_FLG(0x7e6e392074a0)], [B.OPE_END_DATE(0x7e6e39207790)], [B.SALE_TYPE(0x7e6e39207a80)], [B.OPERATING_AGENCIES(0x7e6e39207d70)], [B.SMS_REC_INPUT_DTTM(0x7e6e39208060)], [B.PAYMENT_STANDARD(0x7e6e39208350)], [B.PREMIUM_STANDARD(0x7e6e39208640)], [B.POLICY_PIECES(0x7e6e39208930)], [B.DIGITAL_FLG(0x7e6e39208c20)], [B.INSURE_METHOD(0x7e6e39208f10)], [B.SOURCE_SYSTEM_FLG(0x7e6e39209200)], [B.HOLDER_IDCARD2(0x7e6e392094f0)], [B.ACK_TYPE(0x7e6e392097e0)], [B.CHANNEL_CODE(0x7e6e39209ad0)], [B.ACTIVITY_CODE(0x7e6e39209dc0)], [B.GENJOB_FLG(0x7e6e3920a0b0)], [B.HOLDER_AGE(0x7e6e3920a3a0)], [B.ORGAN4_ID(0x7e6e3920a690)], [B.HESITATE_DAY(0x7e6e3920a980)], [B.LOWEST_RATE(0x7e6e3920ac70)], [B.CRT_USER_ID(0x7e6e3920af60)], [B.CRT_DTTM(0x7e6e3920b250)], [B.LASTUPT_USER_ID(0x7e6e3920b540)], [B.LASTUPT_DTTM(0x7e6e3920b830)], [B.ENABLE_FLG(0x7e6e3920bb20)], [B.ACC_CREATE_FLG(0x7e6e3920be10)], [B.FREE_LOOK_PERIOD(0x7e6e3920c100)], [B.NEWFLAG(0x7e6e3920c3f0)], [B.PROTECT_FLG(0x7e6e3920c6e0)], [B.DEPTNAME(0x7e6e3920c9d0)], [B.SUB_SALE_TYPE(0x7e6e3920ccc0)], [B.DOUBLE_RECORD(0x7e6e3920cfb0)], [B.BQ_OPTION(0x7e6e3920d2a0)], [B.HOLDER_IDCARD_TYPE(0x7e6e3920d590)], [B.HOLDER_OTHER_IDCARD(0x7e6e3920d880)], [B.RECOGNIZEE_IDCARD_TYPE(0x7e6e3920db70)], [B.RECOGNIZEE_OTHER_IDCARD(0x7e6e3920de60)], [B.SUBAMT(0x7e6e3920e150)], [B.RENEW_FLG(0x7e6e3920e440)], [B.PRDCT_TYPE(0x7e6e3920e730)], [B.VIDEO_FLG(0x7e6e3920ea20)], [B.YB_BANK_NAME(0x7e6e3920ed10)], [B.MULTI_RECOGNIZEE_AGE(0x7e6e3920f000)]), filter(nil),
access([B.POLICY_VALID_DATE(0x7e6e391fb6b0)], [B.DATA_ID(0x7e6e391fc690)], [B.BATCH_ID(0x7e6e391fca80)], [B.CMP_TYPE_ID(0x7e6e391fcd70)], [B.ORGAN_ID(0x7e6e391fd060)], [B.ORGAN3_ID(0x7e6e391fd350)], [B.POLICY_NO(0x7e6e391fd640)], [B.CLASS_CODE(0x7e6e391fd930)], [B.POLICY_ATTACH_FLG(0x7e6e391fdc20)], [B.POLICY_STATUS(0x7e6e391fdf10)], [B.POLICY_OPE_DATE(0x7e6e391fe200)], [B.POLICY_PAY_DATE(0x7e6e391fe4f0)], [B.POLICY_PREMIUM(0x7e6e391fe7e0)], [B.POLICY_PAYMETHOD(0x7e6e391fead0)], [B.POLICY_PAYYEARS(0x7e6e391fedc0)], [B.POLICY_PAY_ADDR(0x7e6e391ff0b0)], [B.POLICY_POSTCODE(0x7e6e391ff3a0)], [B.PAYMENT_TEL_AREA(0x7e6e392016a0)], [B.POLICY_PAYMENT_TEL(0x7e6e39201990)], [B.CUSTOMER_ID(0x7e6e39201c80)], [B.HOLDER_IDCARD(0x7e6e39201f70)], [B.HOLDER_NAME(0x7e6e39202260)], [B.HOLDER_SEX(0x7e6e39202550)], [B.WORK_TEL_AREA(0x7e6e39202840)], [B.HOLDER_WORK_TEL(0x7e6e39202b30)], [B.FAMILY_TEL_AREA(0x7e6e39202e20)], [B.HOLDER_FAMILY_TEL(0x7e6e39203110)], [B.MOBILE_TEL_AREA(0x7e6e39203400)], [B.HOLDER_MOBILE_NO(0x7e6e392036f0)], [B.RECOGNIZEE_IDCARD(0x7e6e392039e0)], [B.RECOGNIZEE_NAME(0x7e6e39203cd0)], [B.RECOGNIZEE_GENDER(0x7e6e39203fc0)], [B.RECOGNIZEE_AGE(0x7e6e392042b0)], [B.HOLDER_REC_REL(0x7e6e392045a0)], [B.POLICY_APPDATE(0x7e6e39204890)], [B.CANVASSER_CODE(0x7e6e39204b80)], [B.CANVASSER_NAME(0x7e6e39204e70)], [B.CANVASSER_TEL(0x7e6e39205160)], [B.SALE_CHANNEL(0x7e6e39205450)], [B.BANK_FLG(0x7e6e39205740)], [B.REC_DATE(0x7e6e39205a30)], [B.REC_INPUT_DTTM(0x7e6e39205d20)], [B.SET_CODE(0x7e6e39206010)], [B.ACCO_NO(0x7e6e39206300)], [B.BANK_NAME(0x7e6e392065f0)], [B.HOLDER_BIRTH_DATE(0x7e6e392068e0)], [B.CUSTOMER_TYPE(0x7e6e39206bd0)], [B.OWNER_SOURCE_ID(0x7e6e39206ec0)], [B.INSURED_SOURCE_ID(0x7e6e392071b0)], [B.BUSIMAN_FLG(0x7e6e392074a0)], [B.OPE_END_DATE(0x7e6e39207790)], [B.SALE_TYPE(0x7e6e39207a80)], [B.OPERATING_AGENCIES(0x7e6e39207d70)], [B.SMS_REC_INPUT_DTTM(0x7e6e39208060)], [B.PAYMENT_STANDARD(0x7e6e39208350)], [B.PREMIUM_STANDARD(0x7e6e39208640)], [B.POLICY_PIECES(0x7e6e39208930)], [B.DIGITAL_FLG(0x7e6e39208c20)], [B.INSURE_METHOD(0x7e6e39208f10)], [B.SOURCE_SYSTEM_FLG(0x7e6e39209200)], [B.HOLDER_IDCARD2(0x7e6e392094f0)], [B.ACK_TYPE(0x7e6e392097e0)], [B.CHANNEL_CODE(0x7e6e39209ad0)], [B.ACTIVITY_CODE(0x7e6e39209dc0)], [B.GENJOB_FLG(0x7e6e3920a0b0)], [B.HOLDER_AGE(0x7e6e3920a3a0)], [B.ORGAN4_ID(0x7e6e3920a690)], [B.HESITATE_DAY(0x7e6e3920a980)], [B.LOWEST_RATE(0x7e6e3920ac70)], [B.CRT_USER_ID(0x7e6e3920af60)], [B.CRT_DTTM(0x7e6e3920b250)], [B.LASTUPT_USER_ID(0x7e6e3920b540)], [B.LASTUPT_DTTM(0x7e6e3920b830)], [B.ENABLE_FLG(0x7e6e3920bb20)], [B.ACC_CREATE_FLG(0x7e6e3920be10)], [B.FREE_LOOK_PERIOD(0x7e6e3920c100)], [B.NEWFLAG(0x7e6e3920c3f0)], [B.PROTECT_FLG(0x7e6e3920c6e0)], [B.DEPTNAME(0x7e6e3920c9d0)], [B.SUB_SALE_TYPE(0x7e6e3920ccc0)], [B.DOUBLE_RECORD(0x7e6e3920cfb0)], [B.BQ_OPTION(0x7e6e3920d2a0)], [B.HOLDER_IDCARD_TYPE(0x7e6e3920d590)], [B.HOLDER_OTHER_IDCARD(0x7e6e3920d880)], [B.RECOGNIZEE_IDCARD_TYPE(0x7e6e3920db70)], [B.RECOGNIZEE_OTHER_IDCARD(0x7e6e3920de60)], [B.SUBAMT(0x7e6e3920e150)], [B.RENEW_FLG(0x7e6e3920e440)], [B.PRDCT_TYPE(0x7e6e3920e730)], [B.VIDEO_FLG(0x7e6e3920ea20)], [B.YB_BANK_NAME(0x7e6e3920ed10)], [B.MULTI_RECOGNIZEE_AGE(0x7e6e3920f000)]), partitions(p[0-129]),
is_index_back=false,
range_key([B.DATA_ID(0x7e6e391fc690)], [B.POLICY_VALID_DATE(0x7e6e391fb6b0)]), range(13260601,MIN ; 13260601,MAX),
range_cond([B.DATA_ID(0x7e6e391fc690) = 13260601(0x7e6e391fbf70)])
Used Hint:
-------------------------------------
/*+
*/
Outline Data:
-------------------------------------
/*+
BEGIN_OUTLINE_DATA
FULL(@"SEL$1" "LIFE.B"@"SEL$1")
END_OUTLINE_DATA
*/
Plan Type:
-------------------------------------
DISTRIBUTED
Optimization Info:
-------------------------------------
B:table_rows:114906166, physical_range_rows:1, logical_range_rows:1, index_back_rows:0, output_rows:1, est_method:local_storage, optimization_method=rule_based, heuristic_rule=unique_index_with_indexback
走全局唯一索引的执行计划中,1 号算子只需要访问 1 个分区 partitions(p0),0 号回表算子实际上也只需要访问 1 个分区,因为全局索引的叶子节点上有主键值,而主键是包含分区键的,所以回表时是知道这一行数据的分区键值的,因此可以进行分区裁剪。这里需要注意的是执行计划显示上错误 partitions(p[0-129])。
============================================================
|ID|OPERATOR |NAME |EST. ROWS|COST|
------------------------------------------------------------
|0 |TABLE LOOKUP |B |1 |92 |
|1 | DISTRIBUTED TABLE SCAN|B(UIDX_DATA_ID2)|1 |46 |
============================================================
Outputs & filters:
-------------------------------------
0 - output([B.DATA_ID(0x7efef3480a70)], [B.BATCH_ID(0x7efef3480e60)], [B.CMP_TYPE_ID(0x7efef3481150)], [B.ORGAN_ID(0x7efef3481440)], [B.ORGAN3_ID(0x7efef3481730)], [B.POLICY_NO(0x7efef3481a20)], [B.CLASS_CODE(0x7efef3481d10)], [B.POLICY_ATTACH_FLG(0x7efef3482000)], [B.POLICY_STATUS(0x7efef34822f0)], [B.POLICY_OPE_DATE(0x7efef34825e0)], [B.POLICY_PAY_DATE(0x7efef34828d0)], [B.POLICY_PREMIUM(0x7efef3482bc0)], [B.POLICY_PAYMETHOD(0x7efef3482eb0)], [B.POLICY_PAYYEARS(0x7efef34831a0)], [B.POLICY_PAY_ADDR(0x7efef3483490)], [B.POLICY_POSTCODE(0x7efef3483780)], [B.PAYMENT_TEL_AREA(0x7efef3485a80)], [B.POLICY_PAYMENT_TEL(0x7efef3485d70)], [B.CUSTOMER_ID(0x7efef3486060)], [B.HOLDER_IDCARD(0x7efef3486350)], [B.HOLDER_NAME(0x7efef3486640)], [B.HOLDER_SEX(0x7efef3486930)], [B.WORK_TEL_AREA(0x7efef3486c20)], [B.HOLDER_WORK_TEL(0x7efef3486f10)], [B.FAMILY_TEL_AREA(0x7efef3487200)], [B.HOLDER_FAMILY_TEL(0x7efef34874f0)], [B.MOBILE_TEL_AREA(0x7efef34877e0)], [B.HOLDER_MOBILE_NO(0x7efef3487ad0)], [B.RECOGNIZEE_IDCARD(0x7efef3487dc0)], [B.RECOGNIZEE_NAME(0x7efef34880b0)], [B.RECOGNIZEE_GENDER(0x7efef34883a0)], [B.RECOGNIZEE_AGE(0x7efef3488690)], [B.HOLDER_REC_REL(0x7efef3488980)], [B.POLICY_APPDATE(0x7efef3488c70)], [B.CANVASSER_CODE(0x7efef3488f60)], [B.CANVASSER_NAME(0x7efef3489250)], [B.CANVASSER_TEL(0x7efef3489540)], [B.POLICY_VALID_DATE(0x7efef347fa90)], [B.SALE_CHANNEL(0x7efef3489830)], [B.BANK_FLG(0x7efef3489b20)], [B.REC_DATE(0x7efef3489e10)], [B.REC_INPUT_DTTM(0x7efef348a100)], [B.SET_CODE(0x7efef348a3f0)], [B.ACCO_NO(0x7efef348a6e0)], [B.BANK_NAME(0x7efef348a9d0)], [B.HOLDER_BIRTH_DATE(0x7efef348acc0)], [B.CUSTOMER_TYPE(0x7efef348afb0)], [B.OWNER_SOURCE_ID(0x7efef348b2a0)], [B.INSURED_SOURCE_ID(0x7efef348b590)], [B.BUSIMAN_FLG(0x7efef348b880)], [B.OPE_END_DATE(0x7efef348bb70)], [B.SALE_TYPE(0x7efef348be60)], [B.OPERATING_AGENCIES(0x7efef348c150)], [B.SMS_REC_INPUT_DTTM(0x7efef348c440)], [B.PAYMENT_STANDARD(0x7efef348c730)], [B.PREMIUM_STANDARD(0x7efef348ca20)], [B.POLICY_PIECES(0x7efef348cd10)], [B.DIGITAL_FLG(0x7efef348d000)], [B.INSURE_METHOD(0x7efef348d2f0)], [B.SOURCE_SYSTEM_FLG(0x7efef348d5e0)], [B.HOLDER_IDCARD2(0x7efef348d8d0)], [B.ACK_TYPE(0x7efef348dbc0)], [B.CHANNEL_CODE(0x7efef348deb0)], [B.ACTIVITY_CODE(0x7efef348e1a0)], [B.GENJOB_FLG(0x7efef348e490)], [B.HOLDER_AGE(0x7efef348e780)], [B.ORGAN4_ID(0x7efef348ea70)], [B.HESITATE_DAY(0x7efef348ed60)], [B.LOWEST_RATE(0x7efef348f050)], [B.CRT_USER_ID(0x7efef348f340)], [B.CRT_DTTM(0x7efef348f630)], [B.LASTUPT_USER_ID(0x7efef348f920)], [B.LASTUPT_DTTM(0x7efef348fc10)], [B.ENABLE_FLG(0x7efef348ff00)], [B.ACC_CREATE_FLG(0x7efef34901f0)], [B.FREE_LOOK_PERIOD(0x7efef34904e0)], [B.NEWFLAG(0x7efef34907d0)], [B.PROTECT_FLG(0x7efef3490ac0)], [B.DEPTNAME(0x7efef3490db0)], [B.SUB_SALE_TYPE(0x7efef34910a0)], [B.DOUBLE_RECORD(0x7efef3491390)], [B.BQ_OPTION(0x7efef3491680)], [B.HOLDER_IDCARD_TYPE(0x7efef3491970)], [B.HOLDER_OTHER_IDCARD(0x7efef3491c60)], [B.RECOGNIZEE_IDCARD_TYPE(0x7efef3491f50)], [B.RECOGNIZEE_OTHER_IDCARD(0x7efef3492240)], [B.SUBAMT(0x7efef3492530)], [B.RENEW_FLG(0x7efef3492820)], [B.PRDCT_TYPE(0x7efef3492b10)], [B.VIDEO_FLG(0x7efef3492e00)], [B.YB_BANK_NAME(0x7efef34930f0)], [B.MULTI_RECOGNIZEE_AGE(0x7efef34933e0)]), filter(nil),
partitions(p[0-129])
1 - output([B.DATA_ID(0x7efef3480a70)], [B.POLICY_VALID_DATE(0x7efef347fa90)]), filter(nil),
access([B.DATA_ID(0x7efef3480a70)], [B.POLICY_VALID_DATE(0x7efef347fa90)]), partitions(p0),
is_index_back=false,
range_key([B.DATA_ID(0x7efef3480a70)], [B.shadow_pk_0(0x7efef357f740)], [B.shadow_pk_1(0x7efef357fa30)]), range(13260601,MIN,MIN ; 13260601,MAX,MAX),
range_cond([B.DATA_ID(0x7efef3480a70) = 13260601(0x7efef3480350)])
Used Hint:
-------------------------------------
/*+
INDEX(@"SEL$1" "LIFE.B"@"SEL$1" "UIDX_DATA_ID2")
*/
Outline Data:
-------------------------------------
/*+
BEGIN_OUTLINE_DATA
INDEX(@"SEL$1" "LIFE.B"@"SEL$1" "UIDX_DATA_ID2")
END_OUTLINE_DATA
*/
Plan Type:
-------------------------------------
LOCAL
Optimization Info:
-------------------------------------
B:table_rows:114906166, physical_range_rows:1, logical_range_rows:1, index_back_rows:1, output_rows:1, est_method:local_storage, optimization_method=rule_based, heuristic_rule=unique_index_with_indexback
4结论
这个问题中 OB 集群是非分布式架构(指定了一个 primary zone),全局索引不会带来分布式事务问题。SQL 无法做分区裁剪时,使用了高效的唯一索引,当索引是全局索引时效率最高;当索引是本地索引时,需要访问所有的索引分区,性能会下降。
参考资料
[1]
局部索引和全局索引: https://links.jianshu.com/go?to=https%3A%2F%2Fwww.oceanbase.com%2Fdocs%2Fenterprise-oceanbase-database-cn-10000000000356624