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

planner: can't push down predicates with generated columns down through UnionScan #54870

Closed
qw4990 opened this issue Jul 24, 2024 · 3 comments · Fixed by #54985
Closed

planner: can't push down predicates with generated columns down through UnionScan #54870

qw4990 opened this issue Jul 24, 2024 · 3 comments · Fixed by #54985

Comments

@qw4990
Copy link
Contributor

qw4990 commented Jul 24, 2024

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

mysql> create table t (
         id int,
         `deleted_at` datetime(3) NOT NULL DEFAULT '1970-01-01 01:00:01.000',
         `is_deleted` tinyint(1) GENERATED ALWAYS AS ((`deleted_at` > _utf8mb4'1970-01-01 01:00:01.000')) VIRTUAL NOT NULL,
         key k(id, is_deleted)
     );
Query OK, 0 rows affected (0.02 sec)

mysql> 
mysql> begin;
Query OK, 0 rows affected (0.01 sec)

mysql> insert into t (id, deleted_at) values (1, now());
Query OK, 1 row affected (0.00 sec)

mysql> explain select 1 from t where id=1 and is_deleted=true;
+------------------------------+----------+-----------+----------------------------------+--------------------------------------------+
| id                           | estRows  | task      | access object                    | operator info                              |
+------------------------------+----------+-----------+----------------------------------+--------------------------------------------+
| Projection_5                 | 8000.00  | root      |                                  | 1->Column#5                                |
| └─Selection_6                | 8000.00  | root      |                                  | eq(test.t.id, 1), eq(test.t.is_deleted, 1) |
|   └─UnionScan_7              | 10000.00 | root      |                                  |                                            |
|     └─IndexReader_12         | 10000.00 | root      |                                  | index:IndexFullScan_11                     |
|       └─IndexFullScan_11     | 10000.00 | cop[tikv] | table:t, index:k(id, is_deleted) | keep order:false, stats:pseudo             |
+------------------------------+----------+-----------+----------------------------------+--------------------------------------------+
5 rows in set (0.00 sec)

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

The plan should use IndexRangeScan.

3. What did you see instead (Required)

IndexFullScan

4. What is your TiDB version? (Required)

47179ae

@qw4990 qw4990 added the type/bug The issue is confirmed as a bug. label Jul 24, 2024
@qw4990
Copy link
Contributor Author

qw4990 commented Jul 24, 2024

This is caused by this PR #53981, which is to fix a critical bug.

@ti-chi-bot ti-chi-bot bot closed this as completed in f2abe99 Jul 29, 2024
hawkingrei pushed a commit to hawkingrei/tidb that referenced this issue Aug 1, 2024
@seiya-annie
Copy link

/report customer

@ti-chi-bot ti-chi-bot bot added the report/customer Customers have encountered this bug. label Aug 2, 2024
@kennedy8312
Copy link

/type regression

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants