[英]MySQL PHP: Selecting data from one table and inserting into other in a different DB: Performance wise
我在兩個不同的服務器中有兩個數據庫:db1,db2。 我想將一些數據從一個表轉移到另一個表:從db1.mytable復制到db2.mytable
以下哪個會更好/更快:
答:從db1.mytable中選擇大量行,然后將它們分批發送到db2.mytable
B:的循環(從db1.mytable中選擇少量的行,然后將它們全部一批插入db2.mytable)
例:
A:
SELECT * FROM mytable LIMIT 200000;
while(not_all_fetched)
{
fetch 1000 rows;
insert these 1000 rows into db2.mytable;
}
B:
while(more_rows_to_copy)
{
SELECT * FROM mytable LIMIT 1000;
fetch all of them;
insert these 1000 rows into db2.mytable
}
我同意戴維·賈西(David Jashee)的觀點。 不同服務器上的數據只需要您首先導出它們。
在第一台服務器上,使用“選擇到輸出文件”導出表/列。在服務器2上,使用以下命令導入數據:
這會很快
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.