Details
-
Bug
-
Status: Open (View Workflow)
-
Major
-
Resolution: Unresolved
-
None
-
None
-
Can result in unexpected behaviour
Description
Issue seen in main.sargable_date_cond
Trace output:
------------------------
Capture : trace1.txt
replay : trace2.txt![]()
Capture Explain:
-----------
| {
|
"query_block": { |
"select_id": 1, |
"cost": 0.00524312, |
"nested_loop": [ |
{
|
"table": { |
"table_name": "t1", |
"access_type": "range", |
"possible_keys": ["a"], |
"key": "a", |
"key_length": "6", |
"used_key_parts": ["a"], |
"loops": 1, |
"rows": 2, |
"cost": 0.00524312, |
"filtered": 100, |
"index_condition": "t1.a between '2010-01-01 00:00:00' and '2010-12-31 23:59:59'", |
"attached_condition": "t1.c < (subquery#2)" |
}
|
}
|
],
|
"subqueries": [ |
{
|
"query_block": { |
"select_id": 2, |
"cost": 0.00273041, |
"nested_loop": [ |
{
|
"table": { |
"table_name": "t1", |
"access_type": "range", |
"possible_keys": ["a"], |
"key": "a", |
"key_length": "6", |
"used_key_parts": ["a"], |
"loops": 1, |
"rows": 2, |
"cost": 0.00273041, |
"filtered": 100, |
"attached_condition": "t1.a between '2010-01-01 00:00:00' and '2010-12-31 23:59:59'", |
"using_index": true |
}
|
}
|
]
|
}
|
}
|
]
|
}
|
} |
|
Replay Explain:
----------------
| {
|
"query_block": { |
"select_id": 1, |
"cost": 0.00273041, |
"nested_loop": [ |
{
|
"table": { |
"table_name": "t1", |
"access_type": "range", |
"possible_keys": ["a"], |
"key": "a", |
"key_length": "6", |
"used_key_parts": ["a"], |
"loops": 1, |
"rows": 2, |
"cost": 0.00273041, |
"filtered": 100, |
"index_condition": "t1.a between '2010-01-01 00:00:00' and '2010-12-31 23:59:59'", |
"attached_condition": "t1.c < (subquery#2)" |
}
|
}
|
],
|
"subqueries": [ |
{
|
"query_block": { |
"select_id": 2, |
"cost": 0.00273041, |
"nested_loop": [ |
{
|
"table": { |
"table_name": "t1", |
"access_type": "range", |
"possible_keys": ["a"], |
"key": "a", |
"key_length": "6", |
"used_key_parts": ["a"], |
"loops": 1, |
"rows": 2, |
"cost": 0.00273041, |
"filtered": 100, |
"attached_condition": "t1.a between '2010-01-01 00:00:00' and '2010-12-31 23:59:59'", |
"using_index": true |
}
|
}
|
]
|
}
|
}
|
]
|
}
|
} |
|
How to repro:
----------------
set optimizer_record_context=ON; |
|
|
create table t1 (pk int primary key, a datetime, c int, key(a)); |
|
|
insert into t1 (pk,a,c) values (1,'2009-11-29 13:43:32', 2); |
insert into t1 (pk,a,c) values (2,'2009-11-29 03:23:32', 2); |
insert into t1 (pk,a,c) values (3,'2009-10-16 05:56:32', 2); |
insert into t1 (pk,a,c) values (4,'2010-11-29 13:43:32', 2); |
insert into t1 (pk,a,c) values (5,'2010-10-16 05:56:32', 2); |
insert into t1 (pk,a,c) values (6,'2011-11-29 13:43:32', 2); |
insert into t1 (pk,a,c) values (7,'2012-10-16 05:56:32', 2); |
|
|
explain format=json update t1 set c = 0 |
where year(a) = 2010 and c < (select count(*) from t1 where year(a) = 2010); |
|
|
SELECT context INTO DUMPFILE 'context1.txt' FROM INFORMATION_SCHEMA.OPTIMIZER_CONTEXT; |
source context1.txt
|
Attachments
Issue Links
- relates to
-
MDEV-39368 Add mtr --replay-server option to test Optimizer Context Replay
-
- In Progress
-