Open mzhang77 opened 1 week ago
{
"type":"DataSource",
"property":"",
"info":"table:tb",
"children":[
],
"id":1,
"cost":0,
"selected":false
},
{
"type":"Aggregation",
"property":"",
"info":"funcs:count(1), firstrow(test.tb.object_id), firstrow(test.tb.a), firstrow(test.tb.b), firstrow(test.tb.c)",
"children":[
1
],
"id":3,
"cost":0,
"selected":false
},
{
"type":"Limit",
"property":"",
"info":"offset:0, count:100",
"children":[
3
],
"id":9,
"cost":0,
"selected":false
},
{
"type":"Aggregation",
"property":"",
"info":"funcs:count(1)",
"children":[
9
],
"id":6,
"cost":0,
"selected":false
},
{
"type":"Projection",
"property":"",
"info":"Column#6",
"children":[
6
],
"id":7,
"cost":0,
"selected":false
}
It seems that the outer-most count(1) cause the inner count(1) to get all fields
"funcs:count(1), firstrow(test.tb.object_id), firstrow(test.tb.a), firstrow(test.tb.b), firstrow(test.tb.c)"
Since the index only contains column tb.a and tb.b, IndexLookup is used.
Bug Report
1. Minimal reproduce step (Required)
2. What did you expect to see? (Required)
The execution plan should use index only without accessing table data.
3. What did you see instead (Required)
4. What is your TiDB version? (Required)