mysql - 使用存储过程从不同的临时表更新主表 - MySQL
问题描述
我有以下架构,其中有多个 python 进程将数据批量写入临时表。
为简单起见,让我们考虑有两个 python 进程(p1 和 p2),并将数据推送到 2 个临时表中,如图所示。
我需要创建一个存储过程,它将从临时表(t1、t2、t3 和 t4)中获取数据并更新主表。
Questions:
if i create two stored procedures, (ie. one of each process) , will there be a lock while writing to database. How do we handle that.
For example, both P1 and P2 trigger at the same time and uploads data in temp tables. Now, if we two stored procedures S1 and S2 getting triggered. S1 writes the data into main table. However, S2 will get a WRITE_LOCK (my assumption).
If we have only one stored procedure overall, still the data will be updated sequentially and the python job P2 will have to wait until P1 is getting copied.
The data we are handling is in GBs and has millions of records.
Can you please suggest a suitable solution for this design ?
解决方案
推荐阅读
- windows - 创建OpenGL上下文时如何选择特定的GPU
- firebase - 使用 Cloud Firestore 作为数据库的 Firebase 云功能中真正大的结果集/查询的替代解决方案
- git - Git - 列出最后在主分支中提交的所有文件
- stripe-payments - 用户如何使用条带支付网关通过网上银行进行支付?
- javascript - 使用 GET 请求将数据从站点发送到 js 服务器
- python-3.x - 超级方法调用被覆盖的子方法而不是原始的超级方法
- angular - 属性“用户”在其初始化之前使用 - 在 Angular 中
- python - 上传和运行 Gensim 模型以进行数据增强
- python - ValueError:由于维度不同,使用序列设置数组元素
- python - 在数据库中插入数组/字典/列表(SQLite3,SQLAlchemy)