强读全局索引表路由,是不是有下面三个关键点:
1 首先,是强读分区表
create table t1(c1 int, c2 int, c3 int, c4 int, c5 int, c6 int) partition by key(c1) partitions 8;
select /* +read_consistency(strong) */ * from t1
2 然后,为分区表创建全局索引
create index t1_index on t1(c2,c3,c4)
global partition by range(c2)
(partition p0 values less than (100),
partition p1 values less than (200),
partition p2 values less than (300));
3 最后,在where过滤条件中使用索引列作为查询条件
select /* +read_consistency(strong) / * from t1 where c2=150;
select / +read_consistency(strong) */ c2,c3,c5 from t1 where c2=150;
但是,你看嘛,下面也没有走出这个路由啊:
[2024-08-13 15:28:24.583200] [335][Y0-00007F06309F9610] [ROUTE]((route_diagnosis=
Trans Current Query:"select / +read_consistency(strong) */ * from t1 where c2=150"
Route Prompts
ROUTE_INFO
[INFO] Will use global index table name as real table name to route
PARTITION_ID_CALC_DONE
[WARN] Fail to use partition key value to calculate first part idx
Route Plan
SQL_PARSE:{cmd:“OB_MYSQL_COM_QUERY”, table:“t1”}
ROUTE_INFO:{route_info_type:“USE_GLOBAL_INDEX”}
LOCATION_CACHE_LOOKUP:{mode:“oceanbase”}
TABLE_ENTRY_LOOKUP_DONE:{table:“t1”, table_id:“500002”, table_type:“USER TABLE”, partition_num:3, entry_from_remote:false}
PARTITION_ID_CALC_START:{}
EXPR_PARSE:{col_val:“there are no part keys”}
RESOLVE_EXPR:{part_range:"(MIN ; MAX)always true"}
CALC_PARTITION_ID:{error:-4002, part_description:“partition by hash(INT) partitions 3”}
PARTITION_ID_CALC_DONE:{error:-4002, partition_id:-1, level:1}
ROUTE_INFO:{route_info_type:“USE_CACHED_SESSION”, svr_addr:“10.11.253.63:2881”}
CONGESTION_CONTROL:{svr_addr:“10.11.253.63:2881”}
HANDLE_RESPONSE:{is_parititon_hit:“true”, send_action:“SERVER_SEND_REQUEST”, state:“TRANSACTION_COMPLETE”}
)
[2024-08-13 15:28:37.788133] [335][Y0-00007F06309F9610] [ROUTE]((route_diagnosis=
Trans Current Query:"select / +read_consistency(strong) */ c2,c3,c5 from t1 where c2=150"
Route Prompts
ROUTE_INFO
[INFO] Will do table partition location lookup to decide which OBServer to route to
PARTITION_ID_CALC_DONE
[WARN] Fail to use partition key value to calculate first part idx
Route Plan
SQL_PARSE:{cmd:“OB_MYSQL_COM_QUERY”, table:“t1”}
ROUTE_INFO:{route_info_type:“USE_PARTITION_LOCATION_LOOKUP”}
LOCATION_CACHE_LOOKUP:{mode:“oceanbase”}
TABLE_ENTRY_LOOKUP_DONE:{table:“t1”, table_id:“500002”, table_type:“USER TABLE”, partition_num:3, entry_from_remote:false}
PARTITION_ID_CALC_START:{}
EXPR_PARSE:{col_val:“there are no part keys”}
RESOLVE_EXPR:{part_range:"(MIN ; MAX)always true"}
CALC_PARTITION_ID:{error:-4002, part_description:“partition by hash(INT) partitions 3”}
PARTITION_ID_CALC_DONE:{error:-4002, partition_id:-1, level:1}
ROUTE_INFO:{route_info_type:“USE_CACHED_SESSION”, svr_addr:“10.11.253.63:2881”}
CONGESTION_CONTROL:{svr_addr:“10.11.253.63:2881”}
HANDLE_RESPONSE:{is_parititon_hit:“true”, send_action:“SERVER_SEND_REQUEST”, state:“TRANSACTION_COMPLETE”}
)