stats: TiDB will create the synthesized stats for `tidb_analyze_skip_column_types`
- Dominant language
- Go
- Stars
- 40.5k
- Forks
- 6.2k
- PR merge metrics
- PR metrics pending
Description
## Bug Report
Please answer these questions before submitting your issue. Thanks!
### 1. Minimal reproduce step (Required)
```sql
SET @@session.tidb_analyze_skip_column_types =
'json,blob,mediumblob,longblob,mediumtext,longtext';
SET @@session.tidb_stats_load_sync_wait = 60000;
BLOB case:
CREATE TABLE t_blob2 (
a int DEFAULT NULL,
b blob DEFAULT NULL
);
INSERT INTO t_blob2(a, b) VALUES
(1, 'alpha'), (2, 'beta'), (3, 'gamma'), (4, 'delta'), (5, 'epsilon');
ANALYZE TABLE t_blob2 ALL COLUMNS;
SHOW STATS_HISTOGRAMS
WHERE table_name = 't_blob2'
AND column_name = 'b';
-- Result: empty
ALTER TABLE t_blob2 DROP COLUMN b;
ALTER TABLE t_blob2 ADD COLUMN b blob DEFAULT NULL;
SELECT SLEEP(5);
SELECT h.is_index, h.hist_id, h.distinct_count, h.null_count, h.stats_ver
FROM mysql.stats_histograms h
WHERE h.table_id = (
SELECT tidb_table_id
FROM information_schema.tables
WHERE table_schema = DATABASE()
AND table_name = 't_blob2'
)
ORDER BY h.is_index, h.hist_id;
+----------+---------+----------------+------------+-----------+
| is_index | hist_id | distinct_count | null_count | stats_ver |
+----------+---------+----------------+------------+-----------+
| 0 | 1 | 5 | 0 | 2 |
| 0 | 2 | 0 | 0 | 0 |
| 0 | 3 | 0 | 5 | 0 |
+----------+---------+----------------+------------+-----------+
ANALYZE TABLE t_blob2;
SELECT COUNT(*) FROM t_blob2 WHERE b IS NULL;
SELECT SLEEP(3);
SHOW STATS_HISTOGRAMS
WHERE table_name = 't_blob2'
AND column_name = 'b';
+---------+------------+----------------+-------------+----------+---------------------+------------
----+------------+--------------+-------------+-------------+-----------------+----------------+----
------------+---------------+
| Db_name | Table_name | Partition_name | Column_name | Is_index | Update_time |
Distinct_count | Null_count | Avg_col_size | Correlation | Load_status | Total_mem_usage |
Hist_mem_usage | Topn_mem_usage | Cms_mem_usage |
+---------+------------+----------------+-------------+----------+---------------------+------------
----+------------+--------------+-------------+-------------+-----------------+----------------+----
------------+---------------+
| test | t_blob2 | | b | 0 | 2026-06-15 10:06:45 |
0 | 5 | 0 | 0 | allLoaded | 0 | 0 |
0 | 0 |
+---------+------------+----------------+-------------+----------+---------------------+------------
----+------------+--------------+-------------+-------------+-----------------+----------------+----
------------+---------------+
JSON case:
CREATE TABLE t_json2 (
a int DEFAULT NULL,
j json DEFAULT NULL
);
After ALTER TABLE DROP COLUMN / ADD COLUMN:
+----------+---------+----------------+------------+-----------+
| is_index | hist_id | distinct_count | null_count | stats_ver |
+----------+---------+----------------+------------+-----------+
| 0 | 1 | 5 | 0 | 2 |
| 0 | 2 | 0 | 0 | 0 |
| 0 | 3 | 0 | 5 | 0 |
+----------+---------+----------------+------------+-----------+
After predicate load:
+---------+------------+----------------+-------------+----------+---------------------+------------
----+------------+--------------+-------------+-------------+-----------------+----------------+----
------------+---------------+
| Db_name | Table_name | Partition_name | Column_name | Is_index | Update_time |
Distinct_count | Null_count | Avg_col_size | Correlation | Load_status | Total_mem_usage |
Hist_mem_usage | Topn_mem_usage | Cms_mem_usage |
+---------+------------+----------------+-------------+----------+---------------------+------------
----+------------+--------------+-------------+-------------+-----------------+----------------+----
------------+---------------+
| test | t_json2 | | j | 0 | 2026-06-15 10:06:53 |
0 | 5 | 0 | 0 | allLoaded | 0 | 0 |
0 | 0 |
+---------+------------+----------------+-------------+----------+---------------------+------------
----+------------+--------------+-------------+-------------+-----------------+----------------+----
------------+---------------+
```
### 2. What did you expect to see? (Required)
No synthesized stats for `tidb_analyze_skip_column_types` columns.
### 3. What did you see instead (Required)
```sql
+---------+------------+----------------+-------------+----------+---------------------+------------
----+------------+--------------+-------------+-------------+-----------------+----------------+----
------------+---------------+
| Db_name | Table_name | Partition_name | Column_name | Is_index | Update_time |
Distinct_count | Null_count | Avg_col_size | Correlation | Load_status | Total_mem_usage |
Hist_mem_usage | Topn_mem_usage | Cms_mem_usage |
+---------+------------+----------------+-------------+----------+---------------------+------------
----+------------+--------------+-------------+-------------+-----------------+----------------+----
------------+---------------+
| test | t_json2 | | j | 0 | 2026-06-15 10:06:53 |
0 | 5 | 0 | 0 | allLoaded | 0 | 0 |
0 | 0 |
+---------+------------+----------------+-------------+----------+---------------------+------------
----+------------+--------------+-------------+-------------+-----------------+----------------+----
------------+---------------+
```
The stats are all loaded asynchronously.
### 4. What is your TiDB version? (Required)
master
Contributor guide
Research direction
Start with the ANALYZE TABLE and SHOW STATS_HISTOGRAMS behavior described in the reproduction, then inspect mysql.stats_histograms and the tidb_analyze_skip_column_types setting. Compare the histogram rows created after dropping and re-adding skipped BLOB or JSON columns with the expected empty result. Done means skipped column types do not receive synthesized stats or asynchronous loads.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go, sql
- Domain
- databases
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 47/100