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: allow the optimizer to cache query plans accessing generated columns #45798

Closed
7 tasks done
qw4990 opened this issue Aug 3, 2023 · 0 comments · Fixed by #51654
Closed
7 tasks done

planner: allow the optimizer to cache query plans accessing generated columns #45798

qw4990 opened this issue Aug 3, 2023 · 0 comments · Fixed by #51654

Comments

@qw4990
Copy link
Contributor

qw4990 commented Aug 3, 2023

Enhancement

Work Item Tracking

Description

Currently, queries below are not allowed to be cached since these queries are accessing generated columns:

create table t1 (
    a int,
    info json,
    city varchar(64) as (JSON_UNQUOTE(JSON_EXTRACT(info, '$.city')))
);
prepare s1 from 'select * from t1 where a=?';
show warnings;

create table t2 (
    a int,
    info json,
    city varchar(64) as (JSON_UNQUOTE(JSON_EXTRACT(info, '$.city'))) virtual
);
prepare s2 from 'select * from t2 where a=?';
show warnings;

create table t3 (
    a int,
    info json,
    city varchar(64) as (JSON_UNQUOTE(JSON_EXTRACT(info, '$.city'))) stored
);
prepare s3 from 'select * from t3 where a=?';
show warnings;

create table t4 (
    a int,
    info json,
    index zips( (CAST(info->'$.zipcode' AS UNSIGNED ARRAY)))
);
prepare s4 from 'select * from t4 where a=?';
show warnings;
mysql> show warnings;
+---------+------+----------------------------------------------------------------------------+
| Level   | Code | Message                                                                    |
+---------+------+----------------------------------------------------------------------------+
| Warning | 1105 | skip prepared plan-cache: query accesses generated columns is un-cacheable |
+---------+------+----------------------------------------------------------------------------+
1 row in set (0.00 sec)
@qw4990 qw4990 changed the title planner: allow the optimizer to cache some query plans that access generated columns but generated columns not appear in predicates planner: allow the optimizer to cache some query plans that access generated columns if generated columns not appear in predicates Aug 3, 2023
@qw4990 qw4990 changed the title planner: allow the optimizer to cache some query plans that access generated columns if generated columns not appear in predicates planner: allow the optimizer to cache some query plans accessing generated columns if these generated columns not appear in predicates Aug 3, 2023
@qw4990 qw4990 changed the title planner: allow the optimizer to cache some query plans accessing generated columns if these generated columns not appear in predicates planner: allow the optimizer to cache some query plans accessing generated columns Aug 3, 2023
@qw4990 qw4990 changed the title planner: allow the optimizer to cache some query plans accessing generated columns planner: allow the optimizer to cache query plans accessing generated columns Aug 3, 2023
ti-chi-bot bot pushed a commit that referenced this issue Oct 26, 2023
yibin87 pushed a commit to yibin87/tidb that referenced this issue Oct 31, 2023
ti-chi-bot bot pushed a commit that referenced this issue Mar 7, 2024
…han generating suboptimal plans and caching it when generating MVIndex plans (#51546)

ref #45798
ti-chi-bot bot pushed a commit that referenced this issue Mar 11, 2024
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.

1 participant