[MDEV-8872] Performance regressions with utf8mb4 vs utf8 in WordPress Created: 2015-09-30 Updated: 2023-12-19 Resolved: 2023-09-07 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | Character Sets |
| Affects Version/s: | 10.0.21-galera |
| Fix Version/s: | N/A |
| Type: | Bug | Priority: | Major |
| Reporter: | Gary Pendergast | Assignee: | Sergei Petrunia |
| Resolution: | Duplicate | Votes: | 8 |
| Labels: | None | ||
| Issue Links: |
|
||||||||||||||||||||||||
| Description |
|
When switching tables from utf8 to utf8mb4, we're seeing fairly severe performance regressions - queries that used to run in microseconds, now taking 20 seconds to run. We've run some tests with query and index variations, or there's a summary here. For a direct comparison, see: Here's the WordPress tracking ticket. Comment #2 notes that reducing the meta_key column length to 191 (to match the length of the prefix index) fixes the performance issue, but the utf8 character set doesn't have the same problem. The same behaviour occurs in MySQL, as well. |
| Comments |
| Comment by Ian Gilfillan [ 2016-12-19 ] | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Debian defaults to utf8mb4 so perhaps this should get an increase in priority. | ||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by David Heidelberg [ 2017-06-30 ] | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Would be nice, since Nextcloud 12.0 with News plugin ask to switch DB from utf8 to utf8mb4 . Is any progress with this issue done? | ||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Otto Kekäläinen [ 2020-06-25 ] | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Note that the reporter of this issue Gary Pendergast is one of the core contributors of WordPress. | ||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Alexander Barkov [ 2020-06-26 ] | ||||||||||||||||||||||||||||||||||||||||||||||||
|
This issue is not relevant to utf8 vs utf8mb4 performance. The problem happened because after switch from utf8 to utf8mb4 the non-prefix key on meta_key become a prefix key: The table before the change:
The table after the change:
Notice, the index:
became:
The queries that were used in the performance tests:
Prefix indexes cannot be used for GROUP BY and for ORDER BY because they are not covering. This is by design. This simplified test demonstrates the issue:
In case of the table with a prefix key, the query cannot use indexes. This is expected behaviour. The WordPress team correctly detected the source of the problem, according to this post: | ||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Alexander Barkov [ 2020-06-26 ] | ||||||||||||||||||||||||||||||||||||||||||||||||
|
otto, thanks for your comment. This issue should have been closed as not a bug earlier. Closing now. | ||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Michael Widenius [ 2023-09-07 ] | ||||||||||||||||||||||||||||||||||||||||||||||||
|
This issue is superseded by |