mysql:performance_using_case_insensitive_columns
Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
mysql:performance_using_case_insensitive_columns [2016/07/03 10:50] – created peter | mysql:performance_using_case_insensitive_columns [2020/07/15 09:30] (current) – external edit 127.0.0.1 | ||
---|---|---|---|
Line 8: | Line 8: | ||
<code mysql> | <code mysql> | ||
- | SELECT BENCHMARK(500000000, | + | SELECT BENCHMARK(500000000, |
</ | </ | ||
Line 14: | Line 14: | ||
<code mysql> | <code mysql> | ||
- | 1 row in set (5.88 sec) | + | 1 row in set (7.82 sec) |
</ | </ | ||
Line 21: | Line 21: | ||
<code mysql> | <code mysql> | ||
- | SELECT BENCHMARK(500000000, | + | SELECT BENCHMARK(500000000, |
</ | </ | ||
Line 28: | Line 28: | ||
<code mysql> | <code mysql> | ||
- | 1 row in set (16.27 sec) | + | 1 row in set (21.25 sec) |
</ | </ | ||
- | As you can see, though, case sensitive was nearly three (2.77) | + | As you can see, though, case sensitive was nearly three times faster than case insensitive. |
- | My suggestion to you is that unless you need the column | + | Therefore it is recommended |
- | For CHAR and VARCHAR other character sets also have case insensitive versions, and if not you can alter the column to be VARCHAR BINARY: | + | That is to use **utf8mb4_bin** instead of **utf8mb4_generic_ci**. |
+ | |||
+ | It would be good to alter the column to be VARCHAR BINARY: | ||
<code mysql> | <code mysql> | ||
ALTER TABLE `mytable1` CHANGE `mycolumn` `mycolumn` VARCHAR(254) BINARY NOT NULL; | ALTER TABLE `mytable1` CHANGE `mycolumn` `mycolumn` VARCHAR(254) BINARY NOT NULL; | ||
</ | </ | ||
- | + | ||
- | However, I don't think that's ideal, instead | + | However. if you do need to use a case-insensitive character set, then consider that CHAR and VARCHAR also have case insensitive versions. |
+ | |||
+ | Here's a little chart for which to change to: | ||
|CHAR| BINARY| | |CHAR| BINARY| |
mysql/performance_using_case_insensitive_columns.1467543021.txt.gz · Last modified: 2020/07/15 09:30 (external edit)