当前位置:网站首页>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
边栏推荐
猜你喜欢
随机推荐
Detailed explanation of redirection and request forwarding
Go语言条件,循环,函数
幂等性的处理
如果conda找不到想要安装的库怎么办PackagesNotFoundError: The following packages are not available from current
What if the server is poisoned? How does the server prevent virus intrusion?
shell脚本中的DATE日期计算
Pytorch中named_parameters、named_children、named_modules函数
【递归之数的拆分】n分k,限定范围的拆分
提取不重复的整数
PHP 的运算符
What is CNAs certification? What are the software evaluation centers recognized by CNAs?
时序模型:长短期记忆网络(LSTM)
Mysql database explanation (10)
Use of common pod controller of kubernetes
Mysql database explanation (IX)
Neodynamic Barcode Professional for WPF V11.0
T2 iCloud日历无法同步
Crawling fragment of a button style on a website
kubernetes之常用Pod控制器的使用
Rsync + inotify remote synchronization