Bug #101705 | Optimizer spends several seconds to produce query plan | ||
---|---|---|---|
Submitted: | 21 Nov 2020 8:01 | Modified: | 23 Nov 2020 14:30 |
Reporter: | Aftab Khan | Email Updates: | |
Status: | Verified | Impact on me: | |
Category: | MySQL Server: Optimizer | Severity: | S2 (Serious) |
Version: | 5.7.32 | OS: | Any |
Assigned to: | CPU Architecture: | Any |
[21 Nov 2020 8:01]
Aftab Khan
[21 Nov 2020 8:03]
Aftab Khan
table bar sql dump
Attachment: bar.sql (application/octet-stream, text), 738.28 KiB.
[21 Nov 2020 8:04]
Aftab Khan
sql query
Attachment: slow_in_query.gz (application/x-gzip, text), 280.38 KiB.
[21 Nov 2020 14:37]
Aftab Khan
simplified test: echo 'create database bar; CREATE TABLE `bar`.`foo` ( `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT, `d` int(10) unsigned NOT NULL DEFAULT '0', `u` int(10) unsigned NOT NULL DEFAULT '0', PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; insert into bar.foo values();' | mysql -v for t in {1..5}; do mysql bar -e 'insert into foo select null,1,0 from foo f1 inner join foo f2;' -vvv ; done ids=$(mysql foo -Nse 'select id from foo where id between 1 and 25000' | awk '{printf fmt,$1}' fmt="%s\n" | paste -sd, - ) echo "set profiling=1;set range_optimizer_max_mem_size=8388608*2;explain select id from foo where id in ($ids) and id in ($ids) and u=False; show profile for query 2" | mysql foo -vv -------------- id select_type table partitions type possible_keys key key_len ref rows filtered Extra 1 SIMPLE foo NULL range PRIMARY PRIMARY 8 NULL 24687 10.00 Using where -------------- show profile for query 2 -------------- Status Duration starting 0.022625 checking permissions 0.000023 Opening tables 0.000068 init 0.008634 System lock 0.000029 optimizing 0.003491 statistics 4.897413 <<< preparing 0.000722 explaining 0.007031 end 0.000005 query end 0.000248 closing tables 0.000009 freeing items 0.003310 cleaning up 0.001280
[23 Nov 2020 8:30]
MySQL Verification Team
Hello Aftab, Thank you for the report and testcase. regards, Umesh
[22 Sep 2022 17:18]
Perry Harrington
Hi Umesh, after talking with Aftab and reading this bug report, I believe this should affect 8 as well. I was the engineer who handled the original bug report that lead to the optimizer mem size limit. Thanks, --Perry