Bug #114114 | Filesort does not compare VARCHAR column past 341 matching characters | ||
---|---|---|---|
Submitted: | 26 Feb 5:56 | Modified: | 27 Feb 22:29 |
Reporter: | Jacob Lucke | Email Updates: | |
Status: | Verified | Impact on me: | |
Category: | MySQL Server: Documentation | Severity: | S2 (Serious) |
Version: | 8.0.36 | OS: | Any |
Assigned to: | CPU Architecture: | Any |
[26 Feb 5:56]
Jacob Lucke
[26 Feb 6:45]
MySQL Verification Team
Hello Jacob, Thank you for the report and feedback. Verified as described. regards, Umesh
[26 Feb 19:17]
Knut Anders Hatlen
Hi Jacob, Could it be that you are hitting the limitation documented here: https://dev.mysql.com/doc/refman/8.0/en/server-system-variables.html#sysvar_max_sort_lengt... ? Possible workarounds are increasing max_sort_length, or using a NO PAD collation such as utf8mb4_0900_bin instead of utf8mb4_bin.
[27 Feb 22:29]
Jacob Lucke
Hi Knut, Thanks for your prompt response. Increasing max_sort_length or using a NO PAD collation produces the expected results. Can the documentation you linked be updated to mention window functions? Since this limitation exists in filesort, it is not clear from the documentation to change max_sort_length besides when using GROUP BY, ORDER BY, or DISTINCT. E.g. if I insert 342 character long strings in a pattern ending with 1 2 1 2 1 2, then ROW_NUMBER will not properly count the rows since they do not get sorted due to the max_sort_length limitation: mysql> select col1, right(col2,3), row_number() over(partition by col2) count from incorrectWindow; +------+---------------+-------+ | col1 | right(col2,3) | count | +------+---------------+-------+ | 1 | aa1 | 1 | | 2 | aa2 | 1 | | 3 | aa1 | 1 | | 4 | aa2 | 1 | | 5 | aa1 | 1 | | 6 | aa2 | 1 | +------+---------------+-------+ 6 rows in set (0.00 sec) mysql> set session max_sort_length=@@max_sort_length*2; Query OK, 0 rows affected (0.00 sec) mysql> select col1, right(col2,3), row_number() over(partition by col2) count from incorrectWindow; +------+---------------+-------+ | col1 | right(col2,3) | count | +------+---------------+-------+ | 1 | aa1 | 1 | | 3 | aa1 | 2 | | 5 | aa1 | 3 | | 2 | aa2 | 1 | | 4 | aa2 | 2 | | 6 | aa2 | 3 | +------+---------------+-------+ 6 rows in set (0.00 sec)
[29 Feb 8:51]
Knut Anders Hatlen
Changing bug category to documentation, so that the docs team can take a look at it. I agree that it sounds reasonable to mention in the documentation of the max_sort_length system variable that it also affects WINDOW operations.