[MDEV-16871] in_predicate_conversion_threshold cannot be set in my.cnf Created: 2018-08-01 Updated: 2019-10-28 Resolved: 2019-09-04 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | Variables |
| Affects Version/s: | 10.3.6 |
| Fix Version/s: | 10.3.18, 10.4.8 |
| Type: | Bug | Priority: | Critical |
| Reporter: | Andrew Hutchings (Inactive) | Assignee: | Sergei Golubchik |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Issue Links: |
|
||||||||||||||||||||||||||||
| Description |
|
Currently testing 10.3.6 but looking at code this is still true in current 10.3. Any setting of in_predicate_conversion_threshold in my.cnf is overridden in init_common_variables() with this line:
Removing this line appears to fix the problem. A default is set in sys_vars.cc anyway I don't think this is needed. This affects ColumnStore because we need to set this high. As a side note, I couldn't see this variable documented in KB. |
| Comments |
| Comment by Elena Stepanova [ 2018-08-01 ] | |||||||||
|
According to the commit comment, it might be intentional:
Assigning to serg to clarify.a | |||||||||
| Comment by Andrew Hutchings (Inactive) [ 2018-08-01 ] | |||||||||
|
If there is a way for an engine to access the conversion (I think it is a derived temp table) or some kind of flag an engine can set to turn this off then I would also be happy with that. | |||||||||
| Comment by Sergei Golubchik [ 2018-08-09 ] | |||||||||
|
As long as you have a different server source tree you can change IN_SUBQUERY_CONVERSION_THRESHOLD or set global_system_variables.in_subquery_conversion_threshold when your engine is initialized. But we'll have to think of something better for 10.4. | |||||||||
| Comment by jocelyn fournier [ 2019-03-06 ] | |||||||||
|
Hi Sergei Why did you move this variable as debug-only? In some case the original optimization is not as efficient as expected, and it would really be great to be able to control this variable. Thanks! | |||||||||
| Comment by Sergei Golubchik [ 2019-03-24 ] | |||||||||
|
joce,
Of course, I was asking the wrong question. Even if user will never need to tune the conversion threshold, there can still be a good reason to be able to disable it. I agree it would be good to have a way to disable this optimization. | |||||||||
| Comment by Slawomir Pryczek [ 2019-07-17 ] | |||||||||
|
I think this is needed urgently, because this feature is so broken, buggy and random it can turn a tiny select into nested full table scan which requires to scan billions of rows to get some small dataset from 100k rows tables. So it'll randomly turn 2-3s SELECT's into something which could take 5-10 minutes at best. Because i also saw queries which after this "optimization" took so long that they needed to be kill'ed, so im not even sure how bad can it get! Before it was couple seconds! https://jira.mariadb.org/browse/MDEV-17795 Basically i think the feature is providing no benefit and implementation is probably so complicated that it should be removed altogether ASAP, because how many problems it makes, which are in addition very hard to diagnose, due to how random and unexpected they are. Really if IN (..) is so large memory is a concern, in such rare cases temporary table can be created manually and it can be properly INDEXED and added to a proper join, instead of making totally suboptimal subquery, automatically. For sure, if IN (..) size is a concern then resulting query could probably never finish, due to how bad it works... so this optimization has no purpose because of how randomly it works, and you're risking totally killing your server if it ever gets applied! Probably not many people are noticing this just because larger IN sets are not very common, and even if it hits them - the query plan could be totally different next time even when query is the same... | |||||||||
| Comment by Slawomir Pryczek [ 2019-07-17 ] | |||||||||
|
@Sergei Golubchik Please speak with people on Maria team, show them all these 3 reports, and try to make this whole "optimization" removed altogether as soon as possible. Even when it works as expected, there's no performance benefit. Moreover these are simplest cases with simple IN on one column. How bad can it get on complex queries? And to make things worse it makes many real and needed optimizations, simply impossible because it forces suboptimal subqueries! We have some servers in production which serve hundreds of thousands requests per minute. 10.4 is actually unusable for us because of this "optimization", and we'd need to rewrite each query to manually create temporary table, insert, add index and do a straight join with forced index. And probably it'd work much worse than implementation in 10.1 anyway... The reason im so sure it needs to be removed and it's so important is that people having a lot of traffic will see the problem straight away and will be able to diagnose it instantly, but people with less loaded servers could be getting random lockups or crashes every couple of months. And they will never know what the problem is... having something which is so bad and so random in production code will make very bad user experience. And some people would even probably need to switch to some other servers because they won't be able to make their code stable. | |||||||||
| Comment by Igor Babaev [ 2019-07-19 ] | |||||||||
|
Slawomir, | |||||||||
| Comment by Slawomir Pryczek [ 2019-07-20 ] | |||||||||
|
Ok i oversimplified this looking from perspective of this pattern which i see a lot and for which we're using IN most of the time. It also happened that the second pattern we're using for optimization also was degraded, however that seems irrelevant because differences weren't significiant (<2x). Realized this was designed for different scenarios so shuldn't call for it being removed. For these 3 points mentioned i meant that even with highest join level enabled a very small differences in table structure or in query, could lead to totally different and unexpected execution times which are very counter intuitive (eg. when you duplicate same WHERE condition twice, query will get executed 40 times faster). Sent some analyze for these 2 patterns on email, hopefully there's some usable info | |||||||||
| Comment by Sergei Golubchik [ 2019-08-16 ] | |||||||||
|
May be we should add an optimizer switch to disable this optimization? igor, what do you think? | |||||||||
| Comment by Sergei Golubchik [ 2019-09-01 ] | |||||||||
| Comment by jocelyn fournier [ 2019-09-01 ] | |||||||||
|
Perhaps setting the switch to off until |