[MDEV-21321] Unnecessary Temporary Table Creation when using EXISTS Created: 2019-12-16 Updated: 2023-04-27 |
|
| Status: | Open |
| Project: | MariaDB Server |
| Component/s: | Optimizer |
| Affects Version/s: | 10.0.36, 10.1.41, 10.4.11, 10.5.15, 10.6.7 |
| Fix Version/s: | 10.4 |
| Type: | Bug | Priority: | Major |
| Reporter: | Mark El-Wakil | Assignee: | Igor Babaev |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Environment: |
Linux |
||
| Description |
|
I have a software product that I use across multiple different server setups that use a variety of MariaDB and MySQL installs. I've been getting a series of error reports that some of these servers have run out of space in /tmp/ due to temporary table usage. I went ahead and created the following case that should reproduce the scenario with a minimal number of columns and tables:
On the majority of MariaDB installs I have tested on, I see that table `b` does the following: Something of note: If I reduce the size of the dataset that goes into the second row of table `a`, a temporary table isn't used. e.g: REPEAT('X', 5000). The cutoff appears to be REPEAT('X', 8097) on several of these installs. This makes me think that there's an issue if the row length is more than 8192 bytes. This may be helpful. On MySQL installs (5.7.28), I get: Note: There is one copy of MariaDB I have encountered running 10.1.43 that does not do this. On this build of the software, I get: for table `b`. The differing behavior between (most) installs of MariaDB and MySQL make me think there's a bug here. Please let me know if I can provide any more information if needed. Thanks. |
| Comments |
| Comment by Mark El-Wakil [ 2022-03-15 ] |
|
An update on this: 1) I tested this on MariaDB 10.5 and 10.6 (10.5.15 and 10.6.7 respectively). This looks like it's still happening on these more current builds of the software. 2) If I do: show table status LIKE "a"; before dropping the tables, it shows that the Avg_row_length is 8192 if I do: REPEAT('X', 8097) However, if I do: REPEAT('X', 8098) the Avg_row_length doubles to 16384. This means that the indexing does not work if the row length is over 8192, even though the whole SQL statement doesn't involve the text field at all. 3) I've noticed, interestingly, that MySQL 8 has started to exhibit the same behavior (8.0.22). I don't know if that helps, but it might help with tracking down where this specifically is working / not working. I'll be filing a ticket with them separately. Please let me know if there's any more information I can provide to help with this. |