[MDEV-337] A query with simple join, where clause and order by <datetime column> desc takes very long when executed with ICP Created: 2012-06-13 Updated: 2012-06-28 Resolved: 2012-06-16 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | None |
| Affects Version/s: | 5.5.24 |
| Fix Version/s: | 5.5.25 |
| Type: | Bug | Priority: | Major |
| Reporter: | roberto spadim | Assignee: | Sergei Petrunia |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Attachments: |
|
| Description |
|
The following query
on the test data (100K rows in t1, 2 rows in t2) takes several seconds on a release build and over a minute on a debug build (and returns an empty set). The same query without DESC, or any of the conditions in WHERE clause finishes in no time. The test data is attached as mdev-337.txt.gz Reproducible on 5.5.23, 5.5.24 and current maria/5.5 revno 3426. Minimal optimizer_switch: Full optimizer_switch (default):
EXPLAIN (with the minimal optimizer_switch):
Test case:
|
| Comments |
| Comment by roberto spadim [ 2012-06-13 ] |
|
maybe mix of myisam and aria engine do this problem????? |
| Comment by Elena Stepanova [ 2012-06-13 ] |
|
Hi Roberto, 1) How many rows (approximately) do you have in the tables? Thank you. |
| Comment by roberto spadim [ 2012-06-13 ] |
|
never = 5012 seconds and i killed the query since some users was trying to INSERT into table and it was after kill -> INSERT gone 'waiting table lock', and done (no more query running) "Name" "Engine" "Version" "Row_format" "Rows" "Avg_row_length" "Data_length" "Max_data_length" "Index_length" "Data_free" "Auto_increment" "Create_time" "Update_time" "Check_time" "Collation" "Checksum" "Create_options" "Comment" "est_mov" "Aria" "10" "Page" "15032596" "479" "7209508864" "68719484928" "6843211776" "0" NULL "2011-01-20 19:07:58" "2012-06-13 14:52:19" "2011-05-15 17:45:01" "latin1_swedish_ci" NULL "page_checksum=1" "" select count show index from est_mov "Table" "Non_unique" "Key_name" "Seq_in_index" "Column_name" "Collation" "Cardinality" "Sub_part" "Packed" "Null" "Index_type" "Comment" "Index_comment" show index from estoque_itens "Table" "Non_unique" "Key_name" "Seq_in_index" "Column_name" "Collation" "Cardinality" "Sub_part" "Packed" "Null" "Index_type" "Comment" "Index_comment" |
| Comment by Elena Stepanova [ 2012-06-14 ] |
|
Hi Roberto, You keep changing your ORDER BY clause, so it's hard to follow. Several times you said that you had a problem with |
| Comment by Elena Stepanova [ 2012-06-14 ] |
|
Thanks Roberto, it's all right, please leave the older posts as is. Please also provide your defaults file (my.cnf or whatever it's called on your server). |
| Comment by Elena Stepanova [ 2012-06-14 ] |
|
On synthetic data I'm getting the same exact execution plan as you provided, but the query finishes momentarily. SELECT COUNT SELECT COUNT SELECT COUNT SELECT COUNT SELECT COUNT SELECT COUNT SELECT COUNT SELECT COUNT Upd: okay, I see you have already added defaults file, thanks. |
| Comment by Elena Stepanova [ 2012-06-14 ] |
|
Just update the field and proceed with whatever data described above you can provide. I've switched to 5.5.23 and the query is still fast for me, so it's not about 5.5.23 / 5.5.24 (please still point at the exact distribution though). |
| Comment by Elena Stepanova [ 2012-06-14 ] |
|
Thanks, I'll try to generate better data now. No need to upload your 14GB just yet, but if possible please take and store the dumps now (first, it will be easier while your system is idle, and second, the data might change later and the problem will be gone). |
| Comment by Elena Stepanova [ 2012-06-14 ] |
|
>> and about two queries... no return yet, should i continue? Not necessarily, if they bother you anyhow, you can kill them. |
| Comment by Elena Stepanova [ 2012-06-14 ] |
|
Hi Roberto, Thank you. I was able to reproduce the problem with your data. set global optimizer_switch = 'index_condition_pushdown=off'; on the running server, and add optimizer_switch=index_condition_pushdown=off to your cnf file for future sessions. |
| Comment by Elena Stepanova [ 2012-06-14 ] |
|
Test data (~6.5 Mb when unpacked). Feed to mysql client before executing the query in question. |
| Comment by Elena Stepanova [ 2012-06-15 ] |
|
Roberto, Setting the switch to OFF is just a workaround, in general it is expected to be ON. Sergei will investigate the problem from the optimizer point of view and will decide whether it's a localized bug which can be fixed in 5.5, in which case the fix will be pushed into one of the next releases (most likely not the nearest one, but possibly the next). If it turns out that the slowdown is a part of a deeper deficiency, it might have to wait longer. |
| Comment by roberto spadim [ 2012-06-15 ] |
|
hummm nice elena |
| Comment by Sergei Petrunia [ 2012-06-16 ] |
|
This is the same problem as https://bugs.launchpad.net/maria/+bug/1000051 . It is fixed, and the fix is in 5.3 and 5.5 trees (=> will be in the next release). Meanwhile, one can use optimizer_switch='index_condition_pushdown=off' as a workaround. |
| Comment by Sergei Petrunia [ 2012-06-16 ] |
|
Verified that the bug can be repeated right-before the mentioned bug was fixed, and is not repeatable right after. |
| Comment by roberto spadim [ 2012-06-28 ] |
|
guys i tested now in production, icp off, and no more problems... thanks |