I have two huge tables. I want to update all fields in the second table with the first if productid and userid matches or insert new if not exist. Will a JOIN be better than a simple UPDATE? What about REPLACE INTO? Can someone help me with the best optimal decision? because the tables are huge.
我有两张大桌子。我想用第一个if productid和userid匹配更新第二个表中的所有字段,如果不存在则插入new。 JOIN会比简单的UPDATE更好吗? REPLACE INTO怎么样?有人可以帮我做出最佳的最佳决策吗?因为桌子很大。
Thanks.
1 个解决方案
#1
1
100 billion is pretty rare so I assume you won't find a reliable answer on *.
1000亿是非常罕见的,所以我假设你不会在*上找到可靠的答案。
You should do your own benchmarks, look at the EXPLAIN keyword on mysql.com and write a short script (php one here) to analyze the time spent.
你应该做自己的基准测试,查看mysql.com上的EXPLAIN关键字并编写一个简短的脚本(这里是php)来分析花费的时间。
On a parallel note, I'm not sure whether MySQL is the best choice for a 100 billion database.
同时,我不确定MySQL是否是1000亿数据库的最佳选择。
#1
1
100 billion is pretty rare so I assume you won't find a reliable answer on *.
1000亿是非常罕见的,所以我假设你不会在*上找到可靠的答案。
You should do your own benchmarks, look at the EXPLAIN keyword on mysql.com and write a short script (php one here) to analyze the time spent.
你应该做自己的基准测试,查看mysql.com上的EXPLAIN关键字并编写一个简短的脚本(这里是php)来分析花费的时间。
On a parallel note, I'm not sure whether MySQL is the best choice for a 100 billion database.
同时,我不确定MySQL是否是1000亿数据库的最佳选择。