To meet this requirement, the database needs to be sorted by Alphabet, while the mysql database uses utf encoding.
If gbk is used, the sorting rules are in pinyin format.
The convert function in mysql can convert data.
We have carried out a simple performance test on this convert. The following describes the test process and test results. If you have any questions, please point out.
Software and hardware environment
Hardware configuration: 2-core CPU, 2 GB memory
Database: Mysql 5.5
Table structure
1
2
3
4
5
|
Create table 'test _ gbk '(
'Id' int (11) not null AUTO_INCREMENT,
'Name' varchar (12) default null,
Primary key ('id ')
) ENGINE = InnoDB
|
Test cases
Test SQL:
Select * from test_gbk order by convert (name using gbk) limit 1;
Select * from test_gbk order by name limit 1 ;"
Test Objectives
Use the preceding two SQL statements to test the stress test of 4 threads and 16 threads respectively, focusing on QPS
Test results
40 thousand rows of data
4 threads, performance down 14%
16 threads with a performance reduction of 17%
10 thousand rows of data
4 threads, performance down 15%
16 threads with a performance reduction of 15%
Conclusion
From a simple test, we can see that,
Performance drops within the range of 14%-17%.
Whether or not you want to use this function.
My suggestion is not to use it whenever possible, because compared with front-end applications, I think the computing resources of database servers are more precious.