Bug #68350 | query proc - re-execute of stored routine, inefficient query plan | ||
---|---|---|---|
Submitted: | 12 Feb 2013 14:00 | Modified: | 29 May 2013 17:30 |
Reporter: | Aleks Pol | Email Updates: | |
Status: | Closed | Impact on me: | |
Category: | MySQL Server: Optimizer | Severity: | S1 (Critical) |
Version: | 5.6.11 | OS: | Any (7) |
Assigned to: | CPU Architecture: | Any | |
Tags: | query proc |
[12 Feb 2013 14:00]
Aleks Pol
[13 Feb 2013 13:48]
MySQL Verification Team
Hi Alex, Please help us to narrow down the cause. Please send us the schema? mysqldump --no-defaults -uroot -p --all-databases --no-data --routines > out.sql
[16 Feb 2013 12:35]
MySQL Verification Team
Hi Aleks, I made what I believe to be a simple testcase. Please, check it. ------------- drop table if exists `t1`; create table `t1`(`a` int,key(`a`))engine=innodb; insert into `t1` values (1),(2),(3),(4),(5),(6),(7); insert into `t1` select `t1`.`a` from `t1`,`t1` `t2`, `t1` `t3`,`t1` `t4`,`t1` `t5`; drop procedure if exists `p1`; create procedure `p1`() select count(*) from `t1` left join (select `a` from `t1`) `z` on `z`.`a`=`t1`.`a`; call `p1`(); call `p1`(); call `p1`(); flush tables; call `p1`(); call `p1`(); call `p1`(); ------------- I got execution times: mysql> call `p1`(); +----------+ | count(*) | +----------+ | 40387228 | +----------+ 1 row in set (2.15 sec) Query OK, 0 rows affected (2.15 sec) mysql> call `p1`(); +----------+ | count(*) | +----------+ | 40387228 | +----------+ 1 row in set (13.00 sec) Query OK, 0 rows affected (13.00 sec) mysql> call `p1`(); +----------+ | count(*) | +----------+ | 40387228 | +----------+ 1 row in set (12.98 sec) Query OK, 0 rows affected (12.98 sec) ---------------------
[16 Feb 2013 13:00]
MySQL Verification Team
Here is a testcase that is more dramatic. drop table if exists `t1`; create table `t1`(`a` int,key(`a`))engine=innodb; set @a:=9; insert into `t1` values (1),(2),(3),(4),(5),(6),(7),(8),(9); insert into `t1` select @a:=@a+1 from `t1`,`t1` `t2`, `t1` `t3`,`t1` `t4`,`t1` `t5`; drop procedure if exists `p1`; create procedure `p1`() select count(*) from `t1` left join (select `a` from `t1`) `z` on `z`.`a`=`t1`.`a`; call `p1`(); #1 row in set (0.08 sec) call `p1`(); #1 row in set (2 min 21.71 sec)
[19 Apr 2013 7:17]
Aleks Pol
баг остался
[29 May 2013 17:30]
Paul DuBois
Noted in 5.6.12, 5.7.2 changelogs. Indexed on derived tables that were used during the first invocation of a stored procedure were not used in subsequent invocations.