当前位置:网站首页>MySQL enterprise development specification
MySQL enterprise development specification
2022-06-29 18:37:00 【000X000】
MYSQL Development specification arrangement
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 .
边栏推荐
- CentOS 7.5 install MySQL 8.0.27---yum
- 第02章_MySQL的数据目录
- Adobe Premiere foundation - material nesting (animation of Tiktok ending avatar) (IX)
- Anfulai embedded weekly report no. 271: June 20, 2022 to June 26, 2022
- [tcapulusdb knowledge base] tcapulusdb operation and maintenance doc introduction
- MySQL -connector/j driver download
- RocketMQ的tag过滤和sql过滤
- 山东大学项目实训(六)点击事件展示折线图
- Adobe Premiere基础-声音调整(音量矫正,降噪,电话音,音高换挡器,参数均衡器)(十八)
- codeforces每日5题(均1700)-第二天
猜你喜欢

Adobe Premiere基础-编辑素材文件常规操作(脱机文件,替换素材,素材标签和编组,素材启用,便捷调节不透明度,项目打包)(十七)

codeforces每日5题(均1700)-第二天

Amazing pandaverse:meta "borderless, to activate fashion attributes in the new journey of 2.0

面霸篇:MySQL六十六问,两万字+五十图详解!

通过 hosts文件配置本地域名

Adobe Premiere foundation - sound adjustment (volume correction, noise reduction, telephone tone, pitch shifter, parameter equalizer) (XVIII)

第八届“互联网+”大赛 | 云原生赛道邀你来挑战

Us judge ruled that the former security director of Uber accused of covering up hacking must face fraud charges

garbage collector

熊猫跑酷js小游戏代码
随机推荐
记录服务器被入侵病毒:ssh密码被更改登录失败、恶意程序跑满了cpu、jar包启动失败自动kill、一直弹出You have new mail in /var/spool/mail/root
postgis 生成 图形切割
SD6.25集训总结
Encryption and decryption of 535 tinyurl
js将秒转换成“2h30min50s”的格式
山东大学项目实训(八)设计轮播图进入页面
如何在树莓派上使用OAK相机?
jdbc认识上手
If the evaluation conclusion of waiting insurance is poor, does it mean that waiting insurance has been done in vain?
Jar package background startup and log output
Yolov6+tensorrt+onnx: deployment based on win10+tensorrt8+yolov6+onnx
CentOS 7.5 install MySQL 8.0.27---yum
AMAZING PANDAVERSE:META”无国界,来2.0新征程激活时髦属性
[tcapulusdb knowledge base] tcapulusdb doc acceptance - Introduction to creating game area
什么是多范式编程语言,其中的“多范式”是什么意思?
[tcapulusdb knowledge base] tcapulusdb operation and maintenance doc introduction
Adobe Premiere基础-常用的视频特效(边角定位,马赛克,模糊,锐化,手写工具,效果控件层级顺序)(十六)
Record that the server has been invaded by viruses: the SSH password has been changed, the login fails, the malicious program runs full of CPU, the jar package fails to start automatically, and you ha
VMware installation esxi
第八届“互联网+”大赛 | 云原生赛道邀你来挑战