Skip to content
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

TableFullScan uses pseudo stats in determinate mode #48257

Closed
pcqz opened this issue Nov 3, 2023 · 3 comments · Fixed by #51435
Closed

TableFullScan uses pseudo stats in determinate mode #48257

pcqz opened this issue Nov 3, 2023 · 3 comments · Fixed by #51435
Assignees
Labels
affects-7.5 found/gs found by gs severity/major sig/planner SIG: Planner type/bug The issue is confirmed as a bug.

Comments

@pcqz
Copy link

pcqz commented Nov 3, 2023

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

Create a table without indexes, and insert some rows of data. Wait a minute and analyze the table.

mysql> show stats_meta;
+---------+------------+----------------+---------------------+--------------+-----------+
| Db_name | Table_name | Partition_name | Update_time         | Modify_count | Row_count |
+---------+------------+----------------+---------------------+--------------+-----------+
| test    | test       |                | 2023-11-03 10:07:27 |            0 |      2048 |
+---------+------------+----------------+---------------------+--------------+-----------+
1 row in set (0.00 sec)

mysql> explain select * from test;
+-----------------------+---------+-----------+---------------+----------------------+
| id                    | estRows | task      | access object | operator info        |
+-----------------------+---------+-----------+---------------+----------------------+
| TableReader_5         | 2048.00 | root      |               | data:TableFullScan_4 |
| └─TableFullScan_4     | 2048.00 | cop[tikv] | table:test    | keep order:false     |
+-----------------------+---------+-----------+---------------+----------------------+
2 rows in set (0.00 sec)

mysql> set tidb_opt_objective='determinate';
Query OK, 0 rows affected (0.00 sec)

mysql> explain select * from test;
+-----------------------+----------+-----------+---------------+--------------------------------+
| id                    | estRows  | task      | access object | operator info                  |
+-----------------------+----------+-----------+---------------+--------------------------------+
| TableReader_5         | 10000.00 | root      |               | data:TableFullScan_4           |
| └─TableFullScan_4     | 10000.00 | cop[tikv] | table:test    | keep order:false, stats:pseudo |
+-----------------------+----------+-----------+---------------+--------------------------------+
2 rows in set (0.00 sec)

2. What did you expect to see? (Required)

In both modes, the TableFullScan has the correct row count.

3. What did you see instead (Required)

In determinate mode, the TableFullScan has a row count of 10000.

4. What is your TiDB version? (Required)

v7.6.0-alpha-nightly-20231101

@pcqz pcqz added the type/bug The issue is confirmed as a bug. label Nov 3, 2023
@pcqz
Copy link
Author

pcqz commented Nov 3, 2023

/found gs

@seiya-annie
Copy link

discussed with dev, maybe no need to cherry-pick to 6.1,6.5,7.1

@time-and-fate
Copy link
Member

This issue only affects v7.5.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
affects-7.5 found/gs found by gs severity/major sig/planner SIG: Planner type/bug The issue is confirmed as a bug.
Projects
None yet
5 participants