pingcap / pingcap/tidb

EXPLAIN executes heavy subqueries, EXPLAIN ANALYZE shows nothing about them

Open
#66,679 2 comments 0 reactions 0 assignees View on GitHub
contribution severity/moderate sig/planner type/bug
Dominant language
Go
Stars
40.5k
Forks
6.2k
PR merge metrics
PR metrics pending

Description

## Bug Report
### 1. Minimal reproduce step (Required)

I don't know if you'll consider this a bug, just stumbled on it:

Create test dataset:
```sql
create table ten(a int primary key);
insert into ten values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
create table one_k(a int primary key);
insert into one_k select A.a + B.a* 10 + C.a * 100 from ten A, ten B, ten C;
```

```sql
create table t1 (
a int,
index t1_a(a)
);
insert into t1 select a from one_k;

create table t2 (
a int,
b int,
index t2_b(b)
);
insert into t2
select A.a+1000*B.a, A.a+1000*B.a
from one_k A, one_k B;
analyze table t1,t2;
```

This executes in 0.7 sec and neither of EXPLAIN nor EXPLAIN ANALYZE output show any mention of accessing table t2:

```sql
explain select * from t1 where t1.a=3 or t1.a=(select max(t2.a) from t2 where t2.b <999999);
```
If I make the subquery more lightweight it is fast

```sql
explain select * from t1 where t1.a=3 or t1.a=(select max(t2.a) from t2 where t2.b <9);
```

I think a user would expect to see the subquery's query plan.

### 4. What is your TiDB version? (Required)

```
Release Version: v8.5.3-serverless
Edition: Community
Git Commit Hash: 20260209-114bedc955cef0951cd1c3c4f971a4342e269f23
Git Branch: None
UTC Build Time: 2026-02-09 08:41:16
GoVersion: go1.24.4
Race Enabled: false
Check Table Before Drop: false
Store: tikv
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.