当前位置:网站首页>为啥禁用外键约束
为啥禁用外键约束
2022-04-23 15:37:00 【dengk2013】
【阿里JAVA规范】 :不得使用外键与级联,一切外键概念必须在应用层解决
阿里巴巴为什么这么规定?
1.每次做DELETE 或者UPDATE都必须考虑外键约束,会导致开发的时候很痛苦,测试数据极为不方便,也就是说插入一条主记录的时候,这个时候主记录对应的外键,也必须删除或者更新,再比如一个测试员在做压力测试入库1000W数据,那么同时对应的外键记录表也要入库1000W,也就需要造2000W数据,增加工作量
2.性能问题:对于包含主键表的记录,需要入库2张表
3.并发问题:外键约束会启用行级锁 主表写入时会进入阻塞,比如订单明细表和订单总额表存在外键,当增加订单明细表的时候,但是订单总额表写操作没有完成就会导致明细表发生阻塞,线程一直积压导致mysql崩溃。
4.级联删除问题:多层级联删除会让数据变得不可控 ;触发器也严格被禁用
5.数据耦合:数据库层面数据关系产生耦合 数据迁移维护困难
6.如果mysql的数据达到100亿以上,此时需要数据迁移,比如迁移到hbase,由于hbase没有主外键的关系,程序中并没有主外键关系的检查,就不能保证迁移过程中保证数据一致性
版权声明
本文为[dengk2013]所创,转载请带上原文链接,感谢
https://blog.csdn.net/u012222011/article/details/124340571
边栏推荐
- Sorting and replying to questions related to transformer
- MySQL query library size
- WPS品牌再升级专注国内,另两款国产软件低调出国门,却遭禁令
- Common types of automated testing framework ▏ automated testing is handed over to software evaluation institutions
- 如果conda找不到想要安装的库怎么办PackagesNotFoundError: The following packages are not available from current
- Go并发和通道
- Pytorch中named_parameters、named_children、named_modules函数
- php类与对象
- redis-shake 使用中遇到的错误整理
- PHP 的运算符
猜你喜欢
Wechat applet customer service access to send and receive messages
Demonstration meeting on startup and implementation scheme of swarm intelligence autonomous operation smart farm project
c语言---指针进阶
激活函数的优缺点和选择
Detailed explanation of kubernetes (XI) -- label and label selector
Byte interview programming question: the minimum number of K
pgpool-II 4.3 中文手册 - 入门教程
G007-HWY-CC-ESTOR-03 华为 Dorado V6 存储仿真器搭建
[leetcode daily question] install fence
For examination
随机推荐
Educational codeforces round 127 A-E problem solution
字节面试 transformer相关问题 整理复盘
Go并发和通道
函数(第一部分)
Example of time complexity calculation
c语言---指针进阶
Deep learning - Super parameter setting
MySQL installation process (steps for successful installation)
自动化测试框架常见类型▏自动化测试就交给软件测评机构
Special analysis of China's digital technology in 2022
Rsync + inotify remote synchronization
Wechat applet customer service access to send and receive messages
时序模型:门控循环单元网络(GRU)
What role does the software performance test report play? How much is the third-party test report charged?
Cookie&Session
shell脚本中的DATE日期计算
Go语言数组,指针,结构体
Differential privacy (background)
Knn,Kmeans和GMM
el-tree实现只显示某一级复选框且单选