There are many seemingly true "rumors" on the Internet. Of course, they are not malicious. Most of them are because developers are unwilling to take the initiative to research themselves, and instead believe what others say. There are also many rumors about databases, such as "int performance is much higher than char". I recently conducted a performance test on int, long, char, and varchar, and found that there is actually not much performance difference between them: Note: c8=char(8), s8=varchar(8), i8=(bigint), c4=char(4), s4=varchar(4), i4=char(4) Query 1 million rows without index:
Create an index:
Query with index:
in conclusion: No index: Full table scan does not become faster because the data is smaller, but the overall speed is the same, int/bigint as native types is slightly faster by 12%. With index: char and varchar have similar performance, int is slightly faster by 18% In terms of data storage, reading and writing, integers are the same as strings of equal length, but varchar has an extra byte so performance may be slightly affected (1/n). In terms of data operations and comparisons, integers benefit from native support and are therefore slightly faster than strings. If indexes are used, the performance difference between integers and strings is even smaller. In actual development, many developers often use strings such as char(1) and char(4) to represent type enumerations. In my opinion, this approach is the best solution because it is far superior to data types such as int and enum in terms of storage space, computing performance, readability, maintainability, and scalability. You may also be interested in:
|
<<: WeChat applet implements the snake game
>>: Detailed explanation of the use of nohup /dev/null 2>&1
Database migration is a problem we often encounte...
1. Command Introduction The chkconfig command is ...
This article shares the specific code of Vue to r...
Table of contents 1 Review 2 Five strategies for ...
The steps are as follows 1. Create a docker group...
This article mainly introduces the solution to th...
There are two types: (different browsers) 1. Avail...
mysqlslap Common parameter description –auto-gene...
clear:both is used to清除浮動This is the impression I...
1. Install Docker. Reference URL: Docker Getting ...
Border Style The border-style property specifies ...
The error is as follows: Uncaught TypeError: Cann...
Docker Installation There is no need to talk abou...
Table of contents background accomplish Supplemen...
The notepad program is implemented using the thre...