数据库挑战:如何有效地更新100万条记录?(Database challenge: How to Update 1 million records efficiently?)
我正在努力更新我的海量数据库,但由于这个大的更新/比较,我的wamp / Heidisql一直在崩溃。
我有两个数据库表:主表“member_all”(包含300万条记录)和子表:“mobile_results”(包含9,000条记录)。 表的数据库结构如下所示:
主表(“member_all”)
id int(11), name varchar(255), phoneWork varchar(255), phoneMobile varchar(255), phoneMobileNetwork varchar(255)
表中的数据如下所示:
id name phoneWork phoneMobile phoneMobileNetwork 1 bill 061090999990 0789867676 Null 3 billsaasa 06109094399990 076689867676 Null
子表:(“mobile_results”)
id int(11) autoincrement, phoneMobile varchar(255), phoneMobileNetwork varchar(255)
mobile_results中的数据如下所示:
id phoneMobile phoneMobileNetwork 8789 0789867676 Orange 238789 076689867676 O2
9,000手机号码的所有移动网络数据都存储在“mobile_results”中,但是当我尝试比较这两个表时,我卡住了,我的wamp / Heidi sql崩溃了吗?
我的问题是:
如何有效地使用“mobile_results”中的“phoneMobileNetwork”值填充“member_all”?
以下是我尝试的查询:
查询1
我使用限制来划分我的查询。这很慢,并且还需要1周的时间来比较来自mobile_results的9,000条记录。
update member_all,mobile_results set member_all.phoneMobileNetwork=mobile_results.phoneMobileNetwork where member_all.phoneMobile in (SELECT phoneMobile FROM mobile_results limit 1,10);
查询2
update member_all,mobile_results set member_all.phoneMobileNetwork=mobile_results.phoneMobileNetwork where member_all.phoneMobile in (SELECT phoneMobile FROM mobile_results where id <10);
同样不适合大量记录。
请帮助我如何有效地一次更新记录我的“member_all”表。
在这方面,我将不胜感激。
I am struggling to update my massive database but my wamp/Heidisql keeps crashing due to this large update/comparisons.
I have two database tables: main table "member_all" (contains 3 million records) and child table:"mobile_results" (contains 9,000 records). The database structure of tables look like this:
Main Table ("member_all")
id int(11), name varchar(255), phoneWork varchar(255), phoneMobile varchar(255), phoneMobileNetwork varchar(255)
Data in table looks like this:
id name phoneWork phoneMobile phoneMobileNetwork 1 bill 061090999990 0789867676 Null 3 billsaasa 06109094399990 076689867676 Null
Child Table : ("mobile_results")
id int(11) autoincrement, phoneMobile varchar(255), phoneMobileNetwork varchar(255)
Data in mobile_results looks like this:
id phoneMobile phoneMobileNetwork 8789 0789867676 Orange 238789 076689867676 O2
All my mobile network data for 9,000 mobile number is stored in "mobile_results" but when i try to compare both these table ,i get stuck and my wamp/Heidi sql crashes?
My question is :
How can i populate "member_all" with "phoneMobileNetwork" values from "mobile_results" efficiently?
Here are the queries i have tried:
Query 1
i divided my query using limit .This is slow and would also take 1 week to compare 9,000 records from mobile_results.
update member_all,mobile_results set member_all.phoneMobileNetwork=mobile_results.phoneMobileNetwork where member_all.phoneMobile in (SELECT phoneMobile FROM mobile_results limit 1,10);
Query 2
update member_all,mobile_results set member_all.phoneMobileNetwork=mobile_results.phoneMobileNetwork where member_all.phoneMobile in (SELECT phoneMobile FROM mobile_results where id <10);
Same not good for large number of records.
PLEASE help me how can i update records my "member_all" table efficiently in one go.
I would appreciate you help in this regard.
原文:
最满意答案
[object Object]
是默认情况下呈现JavaScript对象的方式。 您的console.log(presenData)
将类似地输出[object Object]
。鉴于您将
presenData
定义为JSON对象,我猜您想在POST
完整地传递它。改变这个:
return $http.post('/api/presentaciones/' + presenData);
对此:
return $http.post('/api/presentaciones/', presenData);
注意逗号。 这将传递
presenData
JSON对象作为请求的主体。我还将logging语句更改为
console.log(JSON.stringify(presenData))
,它将JSON表示呈现给控制台。
[object Object]
is how a JavaScript object is rendered by default. Yourconsole.log(presenData)
will similarly output[object Object]
.Given that you define
presenData
as a JSON object, I'm guessing you want to pass that in its entirety in yourPOST
.Change this:
return $http.post('/api/presentaciones/' + presenData);
to this:
return $http.post('/api/presentaciones/', presenData);
Note the comma. This will pass the
presenData
JSON object as the body of the request.I would also change the logging statement to be
console.log(JSON.stringify(presenData))
, which will render the JSON representation to the console.
相关问答
更多-
我最终解决了这个问题(在freenode上的nerdyworm的一些帮助下)通过在我的路由中指定一个序列化方法,它刚刚返回了我期望的参数: App.CustomListRoute = Em.Route.extend serialize: (params) -> params I ended up resolving this issue (with some help from nerdyworm on freenode) by specifying a serialize method in ...
-
使用AngularJS $ http.post表达服务器状态404错误(Express server status 404 error with AngularJS $http.post)[2023-08-02]
问题是您要发布到localhost:9000 / signup,这是前端,但前端不支持该路由的post方法。 您需要将请求发送到localhost:{YOUR_EXPRESS_SERVER_PORT} /注册。 将此$http.post('/signup', user)更改$http.post('http://localhost:{YOUR_EXPRESS_SERVER_PORT}/signup', user) The problem is that you are posting to localhost ... -
AJAX调用[object%20Object]而不是URL(Symfony)(AJAX calls [object%20Object] instead of URL (Symfony))[2023-08-05]
在做console.log(路径)时,你真的很奇怪,但是它可能会从你调用它的地方改变,因为上下文,也许在某处有一个全局路径变量? 无论如何,有3种方法可以正确地获取该网址: jQuery的: var path = $("#edit-url-js").data("post-url") var path = $("#edit-url-js").attr("data-post-url") 纯Javascript: var path = document.getElementById("#data-post-ur ... -
customPOST的第二个参数应该是表示路径的字符串。 试试这个: var login = Restangular.one('auth/token').customPOST( {grant_type:'password', username:'b@t.com', password:'666666', scope:'app'}, '', {}, { Authorization:'Basic ' + client, ContentType:'ap ...
-
试试这个代码: $http.post("employees.json",newObj) .then(function (response) { employList.push(response.data); }); Eventually I figure out what was wrong. The problem was in my directory structure which I attach on screenshot. Json-server ma ...
-
使用ajaxFileUpload时出现[object%20Object]错误(get [object%20Object] error when using ajaxFileUpload)[2022-09-24]
您正在导航,因为以下行是 location=score_location['location'] <-- that is the line that is doing it. location指向widow.location,所以你正在做 window.location = { ... } 当你不使用var并且变量对window对象有意义时会发生这种情况。 所以宣布它 var location = score_location['location'] You are navigating away b ... -
尝试使用Rails的remote选项作为表单,这是一种使用AJAX处理表单的内置方法。 您的表单(在您的视图中)应如下所示: <%= form_for @contact, url: url_for(:controller => :contacts, :action => :create), remote: true, 'data-type': :json do |f| %> <% end %> 你的控制器可以保持不变 ...
-
错误是POST http://localhost:3000/ 404 (Not Found) 你没有/的邮政路线 你可以像这样创建一个: router.post('/', function(req, res) { // do something w/ req.body or req.files }); 但是,我建议使用express或upload.php 要使用express,您还需要更新角度FileUploader URL The error is POST http://localhost:3000/ ...
-
[object Object]是默认情况下呈现JavaScript对象的方式。 您的console.log(presenData)将类似地输出[object Object] 。 鉴于您将presenData定义为JSON对象,我猜您想在POST完整地传递它。 改变这个: return $http.post('/api/presentaciones/' + presenData); 对此: return $http.post('/api/presentaciones/', presenData); 注意逗 ...
-
发生这种情况是因为new匹配正则表达式[-_\w]+ 。 您必须重新排序网址模式中的网址条目 改变这个: url(r'^post/(?P
[-_\w]+)/$', views.post_detail), url(r'^post/new/$', views.post_new, name='post_new'), 有了这个: url(r'^post/new/$', views.post_new, name='post_new'), url(r'^post/(?P [-_\w]+)/$', ...