use test;
drop table if exists e, lo;
create table e(a int, b int, key idx_a(a), key idx_b(b)) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;
load stats 's/explain_join_stats_e.json';
create table lo(a int(11) NOT NULL AUTO_INCREMENT, PRIMARY KEY (a)) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin AUTO_INCREMENT=30002;
load stats 's/explain_join_stats_lo.json';
explain select count(*) from e, lo where lo.a=e.a and e.b=22336;
id	estRows	task	access object	operator info
StreamAgg_10	1.00	root		funcs:count(1)->Column#5
└─HashJoin_62	19977.00	root		inner join, equal:[eq(test.lo.a, test.e.a)]
  ├─TableReader_35(Build)	250.00	root		data:TableFullScan_34
  │ └─TableFullScan_34	250.00	cop[tikv]	table:lo	keep order:false
  └─IndexLookUp_46(Probe)	19977.00	root		
    ├─IndexRangeScan_43(Build)	19977.00	cop[tikv]	table:e, index:idx_b(b)	range:[22336,22336], keep order:false
    └─Selection_45(Probe)	19977.00	cop[tikv]		not(isnull(test.e.a))
      └─TableRowIDScan_44	19977.00	cop[tikv]	table:e	keep order:false
explain select /*+ TIDB_INLJ(e) */ count(*) from e, lo where lo.a=e.a and e.b=22336;
id	estRows	task	access object	operator info
StreamAgg_9	1.00	root		funcs:count(1)->Column#5
└─IndexJoin_37	19977.00	root		inner join, inner:IndexLookUp_36, outer key:test.lo.a, inner key:test.e.a, equal cond:eq(test.lo.a, test.e.a)
  ├─TableReader_25(Build)	250.00	root		data:TableFullScan_24
  │ └─TableFullScan_24	250.00	cop[tikv]	table:lo	keep order:false
  └─IndexLookUp_36(Probe)	79.91	root		
    ├─Selection_34(Build)	4080.00	cop[tikv]		not(isnull(test.e.a))
    │ └─IndexRangeScan_32	4080.00	cop[tikv]	table:e, index:idx_a(a)	range: decided by [eq(test.e.a, test.lo.a)], keep order:false
    └─Selection_35(Probe)	79.91	cop[tikv]		eq(test.e.b, 22336)
      └─TableRowIDScan_33	4080.00	cop[tikv]	table:e	keep order:false
