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)
Enhancement
Work Item Tracking
index.testto test Plan Cache + MVIndex planner: add more test cases for plan cache with generated columns #51483multi_valued_index.test,multi_valued_index.testto test Plan Cache + MVIndex planner: add more test cases for plan cache with generated columns #51510json_contains/overlapslead to uncacheable plans, choose to generate optimal plans without caching rather than caching sub-optimal plans planner: choose to generate optimal plans without plan cache rather than generating suboptimal plans and caching it when generating MVIndex plans #51546Description
Currently, queries below are not allowed to be cached since these queries are accessing generated columns: