# Copyright 2023 PingCAP, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # Preparation. mysql> drop table if exists test.t mysql> create table test.t (a int, b int) mysql> alter table test.t set tiflash replica 1 mysql> insert into test.t values(1,2),(2,1),(10,15),(15,10),(20,25),(25,10),(18,19),(19,18) mysql> insert into test.t select a + 5, b + 5 from test.t mysql> insert into test.t select a + 5, b + 5 from test.t mysql> insert into test.t select a + 5, b + 5 from test.t mysql> insert into test.t select a + 5, b + 5 from test.t mysql> insert into test.t select a + 5, b + 5 from test.t mysql> insert into test.t select a + 5, b + 5 from test.t mysql> insert into test.t select a + 5, b + 5 from test.t mysql> insert into test.t select a + 5, b + 5 from test.t mysql> insert into test.t select a + 5, b + 5 from test.t func> wait_table test t mysql> use test; set @@tidb_enable_parallel_apply=0; set @@tidb_isolation_read_engines='tiflash'; set @@tidb_enforce_mpp=1; select count(*) from t where a > (select avg(b) from t t1 where t.a > t1.a); +----------+ | count(*) | +----------+ | 4094 | +----------+ mysql> use test; set @@tidb_enable_parallel_apply=0; set @@tidb_isolation_read_engines='tiflash'; set @@tidb_enforce_mpp=1; select count(*) from t where a > (select a from t t1 where t.a > t1.a limit 1); +----------+ | count(*) | +----------+ | 4095 | +----------+ mysql> use test; set @@tidb_enable_parallel_apply=1; set @@tidb_isolation_read_engines='tiflash'; set @@tidb_enforce_mpp=1; select count(*) from t where a > (select avg(b) from t t1 where t.a > t1.a); +----------+ | count(*) | +----------+ | 4094 | +----------+ mysql> use test; set @@tidb_enable_parallel_apply=1; set @@tidb_isolation_read_engines='tiflash'; set @@tidb_enforce_mpp=1; select count(*) from t where a > (select a from t t1 where t.a > t1.a limit 1); +----------+ | count(*) | +----------+ | 4095 | +----------+ # Clean up. mysql> drop table if exists test.t