当前位置:网站首页>MySQL development specification
MySQL development specification
2022-06-24 15:41:00 【Xianling Pavilion】
All database object names must be lowercase and separated by underscores (MySQL Case sensitive , The name should see the meaning of the name , Better not exceed 32 character )
It is forbidden to store pictures in data , File binary data ( Use a file server )
Do not do database stress tests online
Forbidden from development environment , The test environment is directly connected to the production environment database
Limit the number of indexes on each table , It is recommended that the index of a single table should not exceed 5 individual ( Indexing increases query efficiency , But it will reduce the speed of insertion and update )
Avoid using ENUM data type ( modify ENUM Values need to be used ALTER sentence ,ENUM Type of ORDER BY Low operating efficiency , Require additional operations , It is forbidden to use book value as ENUM The enumerated values
Try to define all fields as NOT NULL( Indexes NULL Need extra space to save , So you need to use more memory temporarily , The comparison and calculation should be correct NULL It's worth special treatment )
Use timestamp or datetime Type to store time
Financial related amount data , use decimal type ( No loss of accuracy , No use float and double)
All database object names are prohibited MySQL Reserved keyword
The temporary library table must be in the form of tmp Is prefixed and suffixed with a date (tmp_)
Backup libraries and libraries must be bak Is prefixed and suffixed with a date (bak_)
All column names and column types that store the same data must be consistent .
The character set of database and table should be used uniformly as much as possible utf8( The character set must be uniform , Avoid garbled code caused by character set conversion , Chinese characters utf8 Take up 3 Bytes )
All tables and fields should be annotated COMMENT, Maintain the data dictionary from the beginning
It is recommended to manage big data by physical tables
Try to separate hot and cold data , Reduce the width of the table (mysql Limit maximum storage 4096 Column , There is no limit to the number of lines , However, the total number of bytes per line cannot exceed 65535. Column restriction benefits : Reduce disk io, Ensures a memory cache hit ratio for hot data , Avoid reading useless cold data )
It is forbidden to create a reserved field in a table ( Unable to confirm stored data type , Modify the reserved field type , Will lock the table )
Avoid using double % Number and like, It is strictly forbidden to search for left blur or full blur ( If necessary, please use search engine to solve . Index file has B-Tree The leftmost prefix matching property of , If the value on the left is not determined , Then this cable cannot be used )
Precompiled statements are recommended for database operations
Cross database query is prohibited ( Leave room for data migration and database and table segmentation , Reduce coupling , Reduce risk )
prohibit select * Inquire about ( Consume more cpu and io And network bandwidth resources , Cannot use overlay index )
in Avoid if operation can be avoided , If it can't be avoided , Need to be evaluated carefully in Number of set elements behind , Control in 1000 Within
No use order by rand() Sort at random
Avoid creating redundant and duplicate indexes ( redundancy :index(a,b,c) index(a,b) index(a))
It is forbidden to create a separate index for each column in a table
The most distinguished column is placed on the leftmost side of the union index
Try to put columns with small field lengths on the far left of the union index
Try to avoid using foreign keys ( Prohibit the use of physical foreign keys , Logical foreign keys are recommended )
Use as much as possible union all Instead of union
Split complex large SQL For the multiple small SQL( MySQL One SQL You can only use one CPU Calculate )
For the program to connect to the database account , Follow the principle of minimum authority
More than three tables prohibited join.( need join Field of , Data types must be absolutely consistent ; When multi table associated query , Ensure that the associated field needs to have an index . Even if the double meter join Also pay attention to table indexes 、SQL performance .)
stay varchar When indexing on a field , Index length must be specified , There's no need to index all fields , Determine the index length according to the actual text differentiation .
SQL Objectives of performance optimization : At the very least range Level , The requirement is ref Level , If it could be consts best
Use ISNULL() To determine whether it is NULL value .
Try not to use physical deletion ( Delete directly , If you want to delete it, make a backup in advance ), It's using logical deletion , Use fields delete_flag Do logical deletion , The type is tinyint,0 Indicates not deleted ,1 Indicates that
If there is order by Scene , Note the use of index order .order by The last field is the combination , Part of index , And put it at the end of the index combination order , Avoid file_sort The situation of , Affect query performance .
The source code attachment has been packaged and uploaded to Baidu cloud , You can download it yourself ~
link : https://pan.baidu.com/s/14G-bpVthImHD4eosZUNSFA?pwd=yu27
Extraction code : yu27
Baidu cloud link is unstable , It may fail at any time , Let's keep it tight .
If Baidu cloud link fails , Please leave me a message , When I see it, I will update it in time ~
Open source address
Code cloud address :
http://github.crmeb.net/u/defu
Github Address :
http://github.crmeb.net/u/defu
https://z.itpub.net/article/detail/6D5CA2E8905731A1A784F87B4F4FEA32
边栏推荐
- Linux记录-4.22 MySQL5.37安装(补充)
- Jenkins的便捷式安装
- Design of vga/lcd display controller system based on FPGA (Part 1)
- MySQL toolset: the official export tool mysqlpump
- The 30 pictures bring the network protocol layer by layer to life. It's really fragrant!
- Paper: Google TPU
- Efficient tools commonly used by individuals
- 手机同花顺股票开户安全吗!
- How about stock online account opening and account opening process? Is it safe to open an account online?
- How to build a high-performance go cache Library
猜你喜欢
Bitmap of redis data structure
Step by step introduction to sqlsugar based development framework (9) -- Realizing field permission control with WinForm control

刚刚阿里面软件测试回来,3+1面任职阿里P7,年薪28*15薪

如何扩展aws主机上的磁盘空间

熬夜整理出的软件测试【高频】面试题大全(2022最新)

设备通过国标GB28181接入EasyCVR平台,出现断流情况该如何解决?
Record the range of data that MySQL update will lock

Do you really know the difference between H5 and applet?

国产芯片的赶超,让美国手机芯片龙头高通害怕了,出招应对竞争

MongoDB入門實戰教程:學習總結目錄
随机推荐
【Kubernetes】1
Domestic payment system and payment background construction
QTreeWidget作为单例模式以dll返回的两个问题
MySQL replication series 6- tables related to replication information
如何扩展aws主机上的磁盘空间
Easy installation of Jenkins
Working with collections
This website teaches you to imitate more than 100 well-known websites!
Who do you want to open a stock account? Is online account opening safe?
Step by step introduction to sqlsugar based development framework (9) -- Realizing field permission control with WinForm control
Network engineers must know the network essence knowledge!
How to implement SQLSERVER database migration in container
SF express: please sign for MySQL soul ten
Bitmap of redis data structure
Is it safe for futures companies to open accounts
Ascinema with asciicast2gif for efficient command line terminal recording
The 30 pictures bring the network protocol layer by layer to life. It's really fragrant!
Which account of Dongfang fortune is safer and better
From practical teaching to competition exercise, Tencent experts personally teach Ti-One platform operation strategy!
期货公司开户安全吗