-
Notifications
You must be signed in to change notification settings - Fork 5.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
The result of index join in associated subqueries is wrong #25799
Labels
Comments
plan with wrong result, there is no tidb> tidb> desc analyze select /*+nth_plan(1)*/ t1. `col_float_key_signed`,t1. `col_smallint_undef_signed` from table_20_binary_undef as t1 where t1. `col_float_keed` not in (select `col_float_key_signed` from table_75_binary_undef as t2 where t1. `col_smallint_undef_signed` = t2. `col_tinyint_key_signed`) ;
+------------------------------------+----------+---------+-----------+----------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+-----------+------+
| id | estRows | actRows | task | access object | execution info | operator info | memory | disk |
+------------------------------------+----------+---------+-----------+----------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+-----------+------+
| Projection_8 | 8000.00 | 8 | root | | time:862.8µs, loops:2, Concurrency:5 | test.table_20_binary_undef.col_float_key_signed, test.table_20_binary_undef.col_smallint_undef_signed | 5.98 KB | N/A |
| └─IndexJoin_12 | 8000.00 | 8 | root | | time:831.7µs, loops:2, inner:{total:653.2µs, concurrency:5, task:1, construct:32µs, fetch:595.7µs, build:24.4µs}, probe:6.99µs | anti semi join, inner:IndexLookUp_11, outer key:test.table_20_binary_undef.col_smallint_undef_signed, inner key:test.table_75_binary_undef.col_tinyint_key_signed, equal cond:eq(test.table_20_binary_undef.col_float_key_signed, test.table_75_binary_undef.col_float_key_signed), eq(test.table_20_binary_undef.col_smallint_undef_signed, test.table_75_binary_undef.col_tinyint_key_signed) | 25.8 KB | N/A |
| ├─TableReader_22(Build) | 10000.00 | 20 | root | | time:220.7µs, loops:3, cop_task: {num: 1, max: 151.3µs, proc_keys: 0, rpc_num: 1, rpc_time: 101.4µs, copr_cache_hit_ratio: 0.00} | data:TableFullScan_21 | 370 Bytes | N/A |
| │ └─TableFullScan_21 | 10000.00 | 20 | cop[tikv] | table:t1 | tikv_task:{time:6.07µs, loops:20} | keep order:false, stats:pseudo | N/A | N/A |
| └─IndexLookUp_11(Probe) | 1.25 | 65 | root | | time:549.6µs, loops:2, index_task: {total_time: 189.3µs, fetch_handle: 186.3µs, build: 489ns, wait: 2.54µs}, table_task: {total_time: 1.6ms, num: 1, concurrency: 5} | | 10.8 KB | N/A |
| ├─IndexRangeScan_9(Build) | 1.25 | 65 | cop[tikv] | table:t2, index:col_tinyint_key_signed(col_tinyint_key_signed) | time:181.2µs, loops:3, cop_task: {num: 1, max: 144.9µs, proc_keys: 0, rpc_num: 1, rpc_time: 114.6µs, copr_cache_hit_ratio: 0.00}, tikv_task:{time:39µs, loops:65} | range: decided by [eq(test.table_75_binary_undef.col_tinyint_key_signed, test.table_20_binary_undef.col_smallint_undef_signed)], keep order:false, stats:pseudo | N/A | N/A |
| └─TableRowIDScan_10(Probe) | 1.25 | 65 | cop[tikv] | table:t2 | time:180.6µs, loops:2, cop_task: {num: 1, max: 139.1µs, proc_keys: 0, rpc_num: 1, rpc_time: 107.5µs, copr_cache_hit_ratio: 0.00}, tikv_task:{time:13µs, loops:65} | keep order:false, stats:pseudo | N/A | N/A |
+------------------------------------+----------+---------+-----------+----------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+-----------+------+ |
plan with correct result, there is an tidb> desc analyze select /*+nth_plan(3)*/ t1. `col_float_key_signed`,t1. `col_smallint_undef_signed` from table_20_binary_undef as t1 where t1. `col_float_key_signed` not in (select `col_float_key_signed` from table_75_binary_undef as t2 where t1. `col_smallint_undef_signed` = t2. `col_tinyint_key_signed`) ;
+-------------------------------+----------+---------+-----------+---------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+-----------+---------+
| id | estRows | actRows | task | access object | execution info | operator info | memory | disk |
+-------------------------------+----------+---------+-----------+---------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+-----------+---------+
| Projection_8 | 8000.00 | 3 | root | | time:352.3µs, loops:2, Concurrency:5 | test.table_20_binary_undef.col_float_key_signed, test.table_20_binary_undef.col_smallint_undef_signed | 5.98 KB | N/A |
| └─HashJoin_20 | 8000.00 | 3 | root | | time:329.3µs, loops:2, build_hash_table:{total:223.1µs, fetch:207.5µs, build:15.6µs}, probe:{concurrency:5, total:1.07ms, max:276.1µs, probe:58.2µs, fetch:1.02ms} | anti semi join, equal:[eq(test.table_20_binary_undef.col_smallint_undef_signed, test.table_75_binary_undef.col_tinyint_key_signed)], other cond:eq(test.table_20_binary_undef.col_float_key_signed, test.table_75_binary_undef.col_float_key_signed) | 12.5 KB | 0 Bytes |
| ├─TableReader_24(Build) | 10000.00 | 75 | root | | time:118µs, loops:2, cop_task: {num: 1, max: 166.9µs, proc_keys: 0, rpc_num: 1, rpc_time: 116.3µs, copr_cache_hit_ratio: 0.00} | data:TableFullScan_23 | 915 Bytes | N/A |
| │ └─TableFullScan_23 | 10000.00 | 75 | cop[tikv] | table:t2 | tikv_task:{time:17.9µs, loops:75} | keep order:false, stats:pseudo | N/A | N/A |
| └─TableReader_22(Probe) | 10000.00 | 20 | root | | time:121.6µs, loops:2, cop_task: {num: 1, max: 165µs, proc_keys: 0, rpc_num: 1, rpc_time: 105.9µs, copr_cache_hit_ratio: 0.00} | data:TableFullScan_21 | 370 Bytes | N/A |
| └─TableFullScan_21 | 10000.00 | 20 | cop[tikv] | table:t1 | tikv_task:{time:6.07µs, loops:20} | keep order:false, stats:pseudo | N/A | N/A |
+-------------------------------+----------+---------+-----------+---------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+-----------+---------+
6 rows in set (0.00 sec) |
Closed
The reason is that IndexJoin cannot deal with NULL correctly, and here is a minimal reproducible case:
|
Please edit this comment or add a new comment to complete the following informationNot a bug
Duplicate bug
BugNote: Make Sure that 'component', and 'severity' labels are added 1. Root Cause Analysis (RCA) (optional)2. Symptom (optional)3. All Trigger Conditions (optional)4. Workaround (optional)5. Affected versions6. Fixed versions |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
Bug Report
Please answer these questions before submitting your issue. Thanks!
1. Minimal reproduce step (Required)
1.txt
download and source the 1.txt
The plan is
2. What did you expect to see? (Required)
3. What did you see instead (Required)
4. What is your TiDB version? (Required)
Release Version: v5.0.3
Edition: Community
Git Commit Hash: ad06648
Git Branch: heads/refs/tags/v5.0.3
UTC Build Time: 2021-06-25 10:00:40
GoVersion: go1.13
Race Enabled: false
TiKV Min Version: v3.0.0-60965b006877ca7234adaced7890d7b029ed1306
Check Table Before Drop: false
The text was updated successfully, but these errors were encountered: