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
Preface Now the operating system used by my compa...
One line command docker run -d \ -v /share:/home/...
The previous article has installed the docker ser...
Nowadays, the screen resolution of computer monit...
Cluster Deployment Overview 172.22.12.20 172.22.1...
The effect of this function is similar to vue的pro...
How to make tomcat support https access step: (1)...
Table of contents How to install and configure To...
Preface Recently I found that my friend's met...
1 Implementation Principle This is done using the...
Table of contents Supports multiple types of filt...
By default, Docker runs over a non-networked UNIX...
Effect: Code: <template> <div class=&quo...
Table of contents What is a plugin Writing plugin...
The full name of Blog should be Web log, which me...