| Bug #119190 | Comparing the result of EXISTS(subquery) with a constant severely reduces query performance | ||
|---|---|---|---|
| Submitted: | 19 Oct 2025 12:28 | Modified: | 20 Jan 10:34 |
| Reporter: | Power Gamer | Email Updates: | |
| Status: | Won't fix | Impact on me: | |
| Category: | MySQL Server: Optimizer | Severity: | S5 (Performance) |
| Version: | 8.4.6 | OS: | Any |
| Assigned to: | CPU Architecture: | Any | |
[19 Oct 2025 12:28]
Power Gamer
[16 Jan 15:03]
Øystein Grøvlen
The requested optimization is not implemented, but the work-around should be pretty straight-forward, so we see no reason to fix this.
[20 Jan 10:34]
Power Gamer
"but the work-around should be pretty straight-forward" The workaround is only straight-forward as long as you are in complete control of SQL being generated (i.e. write SQL query yourself). But it is much less so when the SQL query is generated by a library in a high-level scripting language. But more importantly, the _troubleshooting_ of the issue is _not_ straight-forward at all. No sane person will ever expect the performance of a query to severely tank due to comparison with a constant value which logically changes nothing in the query (and of course, this "quirk" of MySQL is not documented anywhere). And also, other DBMS (such as PostgreSQL for example) do not have this issue, and both queries (from my original report) execute equally fast. Taking all of the above into account, I think you should reevaluate your decision about implementing required optimizations in MySQL.
