When in
with a subquery takes too long, try rewriting with a join:
update vars join
table2
on vars.id = table2.id
set unq = 1;
An index on table2.id
would help speed up performance as well.
문제
SET @variable1 = (SELECT id FROM table2);
update vars set unq=1 where id IN @variable1
how to perform the above query. because there are one million rows and sub query taking too much time for update. so how to save all ids of table2 in var and use in second query.
해결책
When in
with a subquery takes too long, try rewriting with a join:
update vars join
table2
on vars.id = table2.id
set unq = 1;
An index on table2.id
would help speed up performance as well.