当前位置:网站首页>Why disable foreign key constraints
Why disable foreign key constraints
2022-04-23 15:39:00 【dengk2013】
【 Ali JAVA standard 】 : Do not use foreign keys and cascades , All foreign key concepts must be solved in the application layer
Why Alibaba stipulates so ?
1. Every time I do DELETE perhaps UPDATE Must consider foreign key constraints , It can lead to painful development , The test data is extremely inconvenient , That is, when inserting a master record , At this time, the foreign key corresponding to the master record , You must also delete or update , Another example is a tester doing a stress test 1000W data , At the same time, the corresponding foreign key record table should also be stored 1000W, You need to build 2000W data , Increase the workload
2. Performance issues : For records containing primary key tables , Need warehousing 2 A watch
3. Concurrency issues : Foreign key constraints enable row level locks When the main table is written, it will enter blocking , For example, there are foreign keys in order details and order total , When adding order details , However, if the write operation of the total order table is not completed, the details will be blocked , Threads are always overstocked, resulting in mysql collapse .
4. Cascade deletion problem : Multiple cascading deletions can make data uncontrollable ; Triggers are also strictly disabled
5. Data coupling : Coupling of data relations at the database level Data migration and maintenance are difficult
6. If mysql The data reached 100 More than hundred million , Data migration is required at this time , For example, migrate to hbase, because hbase There is no relationship between primary and foreign keys , There is no checking of the relationship between main and foreign keys in program , There is no guarantee of data consistency in the migration process
版权声明
本文为[dengk2013]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204231537380128.html
边栏推荐
猜你喜欢
CAP定理
cadence SPB17.4 - Active Class and Subclass
服务器中毒了怎么办?服务器怎么防止病毒入侵?
G007-HWY-CC-ESTOR-03 华为 Dorado V6 存储仿真器搭建
Basic concepts of website construction and management
regular expression
Sorting and replying to questions related to transformer
Special analysis of China's digital technology in 2022
Mobile finance (for personal use)
自主作业智慧农场创新论坛
随机推荐
What exactly does the distributed core principle analysis that fascinates Alibaba P8? I was surprised after reading it
GFS distributed file system (Theory)
What role does the software performance test report play? How much is the third-party test report charged?
Special analysis of China's digital technology in 2022
使用 Bitnami PostgreSQL Docker 镜像快速设置流复制集群
WPS品牌再升级专注国内,另两款国产软件低调出国门,却遭禁令
Explanation of redis database (IV) master-slave replication, sentinel and cluster
APISIX jwt-auth 插件存在错误响应中泄露信息的风险公告(CVE-2022-29266)
Explanation of redis database (I)
开源项目推荐:3D点云处理软件ParaView,基于Qt和VTK
Go语言条件,循环,函数
Control structure (I)
负载均衡器
自主作业智慧农场创新论坛
Detailed explanation of kubernetes (IX) -- actual combat of creating pod with resource allocation list
Wechat applet customer service access to send and receive messages
PHP PDO ODBC将一个文件夹的文件装载到MySQL数据库BLOB列,并将BLOB列下载到另一个文件夹
Precautions for use of dispatching system
G007-hwy-cc-estor-03 Huawei Dorado V6 storage simulator construction
多生成树MSTP的配置