开发者

2k rows update is very slow in MySQL

开发者 https://www.devze.com 2022-12-27 17:35 出处:网络
I have 2 tables: 1. news (450k rows) 2. news_tags (3m rows) There 开发者_运维技巧are some triggers on news table update which updating listings. This SQL executes too long...

I have 2 tables: 1. news (450k rows) 2. news_tags (3m rows)

There 开发者_运维技巧are some triggers on news table update which updating listings. This SQL executes too long...

UPDATE news
SET news_category = some_number
WHERE news_id IN (SELECT news_id
                  FROM news_tags
                  WHERE tag_id = some_number); #about 3k rows

How can I make it faster?

Thanks in advance, S.


If this is a one time update, you may find it better to disable your triggers, run the update, then run a statement that performs what your triggers do in bulk.

0

精彩评论

暂无评论...
验证码 换一张
取 消