【发布时间】:2017-12-27 17:10:58
【问题描述】:
我有两张桌子: 1. 1000万左右数据的用户表 列:token_type、cust_id(主要) 2. pm_tmp 表,200k 数据 列:id(Primary | AutoIncrement), user_id
user_id 是 cust_id 的外键
第一种方法/查询:
update user set token_type='PRIME'
where cust_id in (select user_id from pm_tmp where id between 1 AND 60000);
第二种方法/查询:在这里,我们将针对 60000 条记录分别针对不同的 cust_id 运行以下查询:
update user set token_type='PRIME' where cust_id='1111110';
【问题讨论】:
-
当你测量它时,你得到了什么结果?
-
第二种方法花费的时间更少。但我正试图找出原因。
-
那是因为,第一个查询需要为您的 innodb 缓冲池提供足够的内存才能快速执行。第二个是单个事务查询将需要相对较少的时间。
标签: mysql sql database-performance query-performance sqlperformance