当前位置:网站首页>Experience in database optimization
Experience in database optimization
2022-06-09 22:37:00 【Versatile senior】
Database optimization experience
1、 use PreparedStatement Generally speaking, it's better than Statement High performance , And it can prevent SQL Injection attack
2、 There are foreign key constraints that affect insert and delete performance , If the program can guarantee the integrity of the data , Remove the foreign key when designing the database . Try to use single meter in large e-commerce
3、 Appropriate redundancy is allowed in the table , Use space for time , Improve query efficiency
4、 The user name and password are separated from the user table . In the login service, you only need to query the user name and password .
5、 Use index . select As far as possible need not *, Even if you query all the fields, try to write them out You can use join queries and never subqueries , Because the bottom layer of the subquery is the join query
Use indexes rationally to improve efficiency ( The essence of indexing is a mechanism to improve efficiency , It's essentially a tree ) For often appearing in where Index columns in clause For often appearing in order
by,distinct Index the fields in
Don't always be in DML( Retrieve or modify ) Index on the table of ( It is easy to cause inaccurate index , The solution is rebuild Rebuild , whatever
DML All operations are updates index, This is the price )
Don't index your resume on a small list ( Indexing resumes and maintaining them also consume resources , Create a small table The index will cause the maintenance time of the index to be longer than the data query time )
Limit the number of indexes on the table , The more indexes, the better ( Indexes take up table space , More External maintenance ) Delete rarely used , Unreasonable index
4、 Too much data in the database , What to do when the database is close to crashing ?
1、 Index optimization and SQL Statement optimization is a must , Avoid fuzzy and non indexed queries , The delete operation is performed according to the clustered index , If the deletion and modification operations are too frequent, you still need to consider splitting tables
2、 See the demand , If the demand is not limited , Then divide the tables
3、 Generally, historical data is regularly transferred to other tables ( Add the year and month to the same table name, for example TABLE201205) file . In this way, the pressure of this year's query of this table is also reduced (90% The query volume is concentrated in this year ), Even querying historical data does not affect performance , Strongly recommend !
4 Optimize the table structure according to your business . Sometimes you can consider using space for time .
边栏推荐
- Light detection and ranging (LIDAR)
- M-Arch(雅特力M4)【AT-START-F425测评】No.04 CRC
- Que se passe - t - il si vous appliquez 8G sur une machine avec 4go de mémoire physique?
- Bonner radar sensor q120raq-cn-af19719
- The problem of finding three color flags in C language test 165
- 数字化工程施工企业这样开展“安全生产月”活动
- Define requestanimationframe to execute once a second
- Systematic goal - Fitness collection
- SQL advanced processing
- YUV格式与RGB格式
猜你喜欢

Re summary of mongodb installation, configuration, error handling, crud operation, etc

Aquanee will land in gate and bitmart in the near future, providing a good opportunity for low-level layout

Slightly more complex queries

化工企业双重预防体系数字化综合管理系统

Diligence from childhood

如何实现高效的IM即时通讯长连接自适应心跳保活机制

【BP预测】基于Adaboost的BP神经网络实现数据回归预测附matlab代码

2022安全生產月活動啟動安全生產與疫情防控兩手抓

Gamefi's new departure, aquanee will log in to gate and bitmart on June 9

【图像加密解密】基于混沌序列结合DWT+SVD实现图像加密解密(含相关性检验)含Matlab源码
随机推荐
MySQL的集合运算
June training (day 09) - two point search
【滤波器】基于时变维纳滤波器实现语音去噪含Matlab源码
Bonner barcode reader ve205g1a
Re summary of mongodb installation, configuration, error handling, crud operation, etc
Why fitness?
86. (leaflet house) leaflet military plotting - collection of linear arrows
Gamefi's new departure, aquanee will log in to gate and bitmart on June 9
10 common high-frequency business scenarios that trigger IO bottlenecks
从零开始实现lmax-Disruptor队列(二)多消费者、消费者组间消费依赖原理解析
Matrix transpose of C language test question 170
The little schemer Chinese version
元宇宙或将会取代互联网成为下一个十年,甚至二十年人们主流的生活方式
[Luogu p8330] mode (radical divide and conquer)
The fourth paradigm chenyuqiang: the next generation technology of enterprise intelligent decision-making "reinforcement learning + environmental learning"
[image segmentation] image segmentation based on anisotropic thermal diffusion equation with matlab code
【轴承故障分解】基于 ITD实现轴承故障信号分解含Matlab源码
Learn how to parse SQL from kernel code
设计备忘录解矩阵链(动态规划法)的一些思考
SQL advanced processing