当前位置:网站首页>Database design (3): database maintenance and optimization
Database design (3): database maintenance and optimization
2022-06-26 04:28:00 【good writings make people copy them】
What to do in maintenance and optimization
One . Maintain data dictionary
1. Use third-party tools to maintain the data dictionary
2. Use the prepared column field of the database itself to maintain the data dictionary
Two . Maintain index
How to select the right column to index
1. Appear in the WHERE clause ,GROUP BY clause ,OREDER BY Column in clause
2. Columns with high selectivity should be placed in front of the index
3. Do not include too long data types in the index . Before use only 16 Bytes are indexed , Or fields that are too large , Conduct md5 transformation , Then go to index
matters needing attention :
1. The more indexes, the better , Too many indexes will not only reduce the write efficiency , And it will reduce the efficiency of reading .
Every time you write a record , The index should be maintained , The cost of maintenance is large .
Read operations , because SQL The optimizer will select the appropriate... Based on the index information and statistics sql The index of . If there are too many indexes ,SQL The process by which the optimizer selects an index affects efficiency
2. Maintain index fragmentation on a regular basis
The creation and maintenance of indexes consume , Indexes take up physical space , And with the increase of the amount of data .
3. stay SQL In the sentence Do not use Force index key .
The original index used due to the change of data volume , It may not apply in the future . If forced indexing is used , It will affect the efficiency of the database , If you delete the index , Developers don't know , The query will be wrong .
3、 ... and . Maintenance table structure
matters needing attention :
1. Use online tools to change the structure
Different kinds of triggers can exist in the same table , But there cannot be more than one of the same kind .
2. At the same time, maintain the data dictionary
3、 Control the width and size of the table
The database is suitable for operation
1. The batch operation VS One by one operation
The database is suitable for batch operation , One by one operation is suitable for completion in the program
2. No use select * This kind of operation
Use select * Query and add all columns IO burden , Because the query except for a large number of unused fields
3. Control the use of user-defined functions
Using too many user-defined functions , May affect the index
4. Do not use full-text indexes in the database
Full text indexing requires the creation of additional index files , To maintain the index . And full-text indexing is not very friendly to Chinese support . If you really need it , Suggest using search engine .
Four . Split the table horizontally or vertically when appropriate
1. Split Vertically

2. Horizontal split


边栏推荐
- CDN with OSS acceleration
- Etcd watch principle
- Install cenos in the virtual machine
- Understand CGI and fastcgi
- go语言泛型在IDE中语法报错
- [Qunhui] command line acme SH automatically apply for domain name certificate
- Thinkphp6 implements a simple lottery system
- Tencent Interviewer: How did binder get its system services?
- BSC 及HT 等链的NFT 创造及绑定图片教程
- A brain map to summarize the needs analysis (a supplement to the actual situation at work)
猜你喜欢

微软禁止俄用户下载安装Win10/11

Wechat applet is bound to a dynamic array to implement a custom radio box (after clicking the button, disable the button and enable other buttons)

2020-12-18

CTF serialization and deserialization

Clickhouse stand alone installation

Redis cache data consistency solution analysis

Computer network high frequency interview questions

MySQL index details

PHP small factory moves bricks for three years - interview series - my programming life

Sixtool- source code of multi-functional and all in one generation hanging assistant
随机推荐
Analysis report on development trend and market demand of global and Chinese molecular diagnostics industry from 2022 to 2028
win10 系统打开的软件太小,如何变大(亲测有效)
Ipvs0 network card of IPVS
修改Oracle连接数
Resolve PHP is not an internal or external command
CDN with OSS acceleration
Minecraft 1.16.5 生化8 模组 1.9版本 1.18版本同步
Laravel uses phpword to generate word documents
[从零开始学习FPGA编程-45]:视野篇 - 集成电路助力数字化时代高质量发展-2-市场预测
Yapi cross domain request plug-in installation
35岁程序员炒Luna 千万资产3天归零,网友:和赌博一样
College C language final exam · multiple choice questions · summary notes of mistakes and difficulties
钉钉开放平台-小程序开发实战(钉钉小程序服务器端)
35 year old programmer fired Luna millions of assets and returned to zero in three days. Netizen: it's the same as gambling
mysql自带的性能测试工具mysqlslap执行压力测试
Composer version rollback version switching
WPF value conversion
Development prospect and investment strategic planning report of global and Chinese PVC hose industry from 2022 to 2028
Capture packets (Wireshark)
2021-01-31