What's the difference between utf8_general_ci and utf8_unicode_ci?

后端 未结 8 1212
暗喜
暗喜 2020-11-22 01:38

Between utf8_general_ci and utf8_unicode_ci, are there any differences in terms of performance?

相关标签:
8条回答
  • 2020-11-22 02:16

    See the mysql manual, Unicode Character Sets section:

    For any Unicode character set, operations performed using the _general_ci collation are faster than those for the _unicode_ci collation. For example, comparisons for the utf8_general_ci collation are faster, but slightly less correct, than comparisons for utf8_unicode_ci. The reason for this is that utf8_unicode_ci supports mappings such as expansions; that is, when one character compares as equal to combinations of other characters. For example, in German and some other languages “ß” is equal to “ss”. utf8_unicode_ci also supports contractions and ignorable characters. utf8_general_ci is a legacy collation that does not support expansions, contractions, or ignorable characters. It can make only one-to-one comparisons between characters.

    So to summarize, utf_general_ci uses a smaller and less correct (according to the standard) set of comparisons than utf_unicode_ci which should implement the entire standard. The general_ci set will be faster because there is less computation to do.

    0 讨论(0)
  • 2020-11-22 02:16

    In brief words:

    If you need better sorting order - use utf8_unicode_ci (this is the preferred method),

    but if you utterly interested in performance - use utf8_general_ci, but know that it is a little outdated.

    The differences in terms of performance are very slight.

    0 讨论(0)
提交回复
热议问题