我需要運行一個MySQL腳本,根據我的基準測試,它應該需要14個小時才能運行。該腳本更新每一行的332715行的表:MySQL - 如何通過SSH連接運行長時間(> 14小時)的作業?
UPDATE gene_set SET attribute_fk = (
SELECT id FROM attribute WHERE
gene_set.name_from_dataset <=> attribute.name_from_dataset AND
gene_set.id_from_dataset <=> attribute.id_from_dataset AND
gene_set.description_from_dataset <=> attribute.description_from_dataset AND
gene_set.url_from_dataset <=> attribute.url_from_dataset AND
gene_set.name_from_naming_authority <=> attribute.name_from_naming_authority AND
gene_set.id_from_naming_authority <=> attribute.id_from_naming_authority AND
gene_set.description_from_naming_authority <=> attribute.description_from_naming_authority AND
gene_set.url_from_naming_authority <=> attribute.url_from_naming_authority AND
gene_set.attribute_type_fk <=> attribute.attribute_type_fk AND
gene_set.naming_authority_fk <=> attribute.naming_authority_fk
);
(腳本是不幸的;我需要所有的數據從gene_set
轉移到attribute
,但首先我必須正確設置一個外鍵指向attribute
)。
我一直無法使用此命令成功運行:
nohup mysql -h [host] -u [user] -p [database] < my_script.sql
例如,昨天晚上,它跑了10個小時以上,但隨後的ssh連接朗聲道:
Write failed: Broken pipe
有沒有辦法以某種方式運行此腳本以更好地確保它完成?我真的不在乎需要多長時間(1天vs 2天並不重要),只要我知道它會完成。
其餘部分的影響你有沒有到遠程機器的ssh訪問運行?如果是這樣,你可以在那裏複製腳本並在mysql服務器本地運行它。 – cb0
@gwg該查詢每行都運行一次 - 這就是爲什麼它需要這麼長時間!難道你不能通過更新通過加入數據而不是通過子查詢選擇所需的值來改變它對集合進行操作嗎?這樣你就可以得到一次執行 - 並且可以提高性能。 –