Postgres python psycopg2中的慢速更新
在表 ABC 中,我有60m的记录和9-10列。我在 msg_id(pk)的列上创建了索引。
我有另一个表格为 temp_abc ,其中包含1M记录,还在 msg_id(pk)的列上创建了索引。
现在,我必须更新 abc 表的2列,其中abc.msg_id = temp_abc.msg_id然后设置 abc.col_1 ='static_value_1''和 abc.col_2 ='' static_value_2'
目前需要11分钟才能更新,我想在3-5分钟内进行。是否可以 ?
查询:
f""" update
{tlt_table_name}
set
"MATCH_STATUS"='MATCH',"FINAL_STATUS"='PENDING FOR PROCESSING'
from
{temp_match_report_table} as tm
where
{tlt_table_name}."HEAD_MSG_ID" = tm."HEAD_MSG_ID" """
解释结果:请参阅此处的解释
In the table ABC, I have 60M records and 9-10 columns. I created index on a column which is msg_id(PK).
I have another table which is temp_ABC which contains 1M records, also created index on a column which is msg_id(PK).
now I have to update 2 columns of ABC table where ABC.msg_id = temp_ABC.msg_id then set ABC.col_1='STATIC_VALUE_1' and ABC.col_2='STATIC_VALUE_2'
Currently it is taking 11 minutes to update and I wanted to do it in 3-5 minutes. is it possible ?
query :
f""" update
{tlt_table_name}
set
"MATCH_STATUS"='MATCH',"FINAL_STATUS"='PENDING FOR PROCESSING'
from
{temp_match_report_table} as tm
where
{tlt_table_name}."HEAD_MSG_ID" = tm."HEAD_MSG_ID" """
Explain result : see explain result from here
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论