[MDEV-28991] optimizer aware that inner join implies not null Created: 2022-07-01 Updated: 2022-07-08 |
|
| Status: | Open |
| Project: | MariaDB Server |
| Component/s: | Server |
| Fix Version/s: | None |
| Type: | Task | Priority: | Minor |
| Reporter: | MG | Assignee: | Sergei Petrunia |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | optimizer | ||
| Attachments: |
|
| Description |
|
You can reduce Handler_read_next in an INNER JOIN by specifying the column to be joined IS NOT NULL in the where clause, which is implicitly true:
I kept buffer pool as 128MB since the tables are pretty small on disk and the results are more pronounced when not all data fits in memory. I wanted to include a way to generate this with sequence tables (which is what I used) but a dump file would be a lot easier and takes about 5 minutes to load on my pretty small instance. Is there a way to send a 300+MB file? |
| Comments |
| Comment by MG [ 2022-07-08 ] | |||||||||||||||||||||||||||||||||||||||||
|
The gist is that the explicit IS NOT NULL criteria, on the column to be joined to the left, causes more of the existing index to be used and reduces Handler_read_next. I had previously uploaded a larger dump where effects were more pronounced but I have a minified dump today with these results:
| |||||||||||||||||||||||||||||||||||||||||
| Comment by MG [ 2022-07-08 ] | |||||||||||||||||||||||||||||||||||||||||
|
By the way, I am not sure whether it would matter that t1.id is PK (not null), since join wouldn't match those rows:
|