[MDEV-14956] Slow deletes if number of deleted rows smaller then LIMIT Created: 2018-01-16 Updated: 2018-02-14 Resolved: 2018-02-14 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | Data Manipulation - Delete, Optimizer |
| Affects Version/s: | 10.2.10 |
| Fix Version/s: | N/A |
| Type: | Bug | Priority: | Major |
| Reporter: | Thomas Huppertz | Assignee: | Alice Sherepa |
| Resolution: | Not a Bug | Votes: | 0 |
| Labels: | delete, long, performance | ||
| Environment: |
Windows |
||
| Attachments: |
|
||||||||
| Issue Links: |
|
||||||||
| Description |
|
Have two tables RLOG, RREC which basically Looks like this:
and
(see attachments for full table creation SQL) Both tables have several rows: RLOG: 1 MIO From time to time i want to delete some entrys from RLOG table:
As long as at least 1000 rows are deleted everything is fine:
but if i delete less then 1000 rows the delete Operation takes very long time:
and even worse if nothing is deleted it takes Long time also:
Profiling of such a statement shows the following:
updating |51,634785 |99,86| If you like I can provide you my testdata (6GB). |
| Comments |
| Comment by Alice Sherepa [ 2018-01-18 ] | |||||||||||||||||||||||||||||
|
Hi Thomas, please explain why you consider it is a bug. | |||||||||||||||||||||||||||||
| Comment by Thomas Huppertz [ 2018-01-19 ] | |||||||||||||||||||||||||||||
|
From my original post
but if i delete less then 1000 rows the delete Operation takes very long time:
-------------- So why does deletion of 847 rows takes longer then deleting 1000 rows. Assume you have 1124 rows you want to delete: 1. Case: BAD
2. Case: BAD
3. CASE: GOOD
So you now see the problem?
All other deletion attemps result in a execution time which is factor 240 times slower. | |||||||||||||||||||||||||||||
| Comment by Alice Sherepa [ 2018-01-23 ] | |||||||||||||||||||||||||||||
|
Thomas Huppertz , please provide output of
as a workaround:
| |||||||||||||||||||||||||||||
| Comment by Thomas Huppertz [ 2018-01-23 ] | |||||||||||||||||||||||||||||
|
Form
the output is:
and from
the output is:
| |||||||||||||||||||||||||||||
| Comment by Alice Sherepa [ 2018-01-23 ] | |||||||||||||||||||||||||||||
|
Please provide a testcase. It looks like a bug from your description, but I can not reproduce it. Another case, if we have 124 matching rows, and then DELETE ... LIMIT 123, DELETE ... LIMIT 1 - and we were so lucky, that we met matching rows right from the start of the table, so queries were fast. If we execute DELETE ... LIMIT 1 again and there are no matching rows, we scan the whole table, get result - 0 rows deleted and long query execution. The problem here is, that semi-join optimization for DELETE is not yet implemented( | |||||||||||||||||||||||||||||
| Comment by Thomas Huppertz [ 2018-01-25 ] | |||||||||||||||||||||||||||||
|
In order to provide a test case i Need to upload a fairly large data set. It´s 160MB Zip-File. The SQL for table creation is already attached
Yes, this is correct | |||||||||||||||||||||||||||||
| Comment by Alice Sherepa [ 2018-01-26 ] | |||||||||||||||||||||||||||||
|
please upload it to ftp://ftp.askmonty.org/private/ | |||||||||||||||||||||||||||||
| Comment by Thomas Huppertz [ 2018-01-26 ] | |||||||||||||||||||||||||||||
|
Uploaded as mdev-14956.zip | |||||||||||||||||||||||||||||
| Comment by Thomas Huppertz [ 2018-02-01 ] | |||||||||||||||||||||||||||||
|
Hi Alice, | |||||||||||||||||||||||||||||
| Comment by Alice Sherepa [ 2018-02-02 ] | |||||||||||||||||||||||||||||
|
Yes, thank you. please provide also exact command, that you execute, what is in SQL2.sql? if I execute
there are no matching rows, do I have data after you deleted this rows? | |||||||||||||||||||||||||||||
| Comment by Thomas Huppertz [ 2018-02-07 ] | |||||||||||||||||||||||||||||
|
Sorry for the late response, missed the mal from JIRA somehow. SQL2.sql - this was only from the sqltool i used ... you have multiple SQL-Tabs in there. So you can just ignore this. I have checked the testdata. You could perform the following Statement to reproduce the test case: First test case: no data deletion
As you can see ... the select delivers in 0.11 sec that tehere are no rows to delete. Second test case: with data deleteion:
Think you can figure out the whole problem with this test cases. As Long as you know how many rows to delete - you are fast. Otherwise you are slow. | |||||||||||||||||||||||||||||
| Comment by Alice Sherepa [ 2018-02-14 ] | |||||||||||||||||||||||||||||
|
Hi Thomas,
|