简体   繁体   English

迭代式mysql查询速度变慢

[英]Iterative mysql queries slowing down

I did a quick set of queries to break this: 27JAN2013 into 2013-01-27 in another field. 我进行了一系列快速查询,以打破这一点: 27JAN2013进入另一个领域的2013-01-27年1月27日。 It was easier just to do 12 in a row changing the month to be written for each. 连续执行12来更改每个月份要写的月份会更容易。 What I noticed is each subsequent query took a little bit longer. 我注意到,每个后续查询都花了更长的时间。

The first: 首先:

update 
   hondaacura 
set transdate1 = concat_ws('-',substr(trxdate,6,4),'01', left(trxdate,2)) 
where substr(trxdate,3,3) = 'JAN';  

It took 6.27 to update on a total table size of 3.5 million records. 更新总表大小为350万条记录花费了6.27。

The February statement running next took 6.9, and so on, until December which took 12.3. 接下来运行的2月声明花费6.9,依此类推,直到12月花费12.3。

Why would it slow down with each subsequent query? 为什么随后的每个查询都会放慢速度?

I think you can solve this with this update statement. 我认为您可以使用此更新语句解决此问题。 Then you don't need to write 12 statements and execute them in a row. 然后,您无需编写12条语句并连续执行它们。

update 
   hondaacura 
set transdate1 = STR_TO_DATE(trxdate, '%d%b%Y');

For more info see here . 有关更多信息,请参见此处

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM