I need to update a table except its top 1000 records. My request is as follows:
UPDATE tableA SET price = 100 WHERE price = 200 AND item_id =12 AND status NOT IN (1,2,3);
I know that subquery approcah will work here, but I have a huge table in which 200,000 records satisfy the WHERE and it grows. Therefore, I think that if I follow the subprocess approach, it will not scale as the database grows.
I also saw the LIMIT in UPDATE , but it is up to a certain limit. In my case, this happens after a certain offset and should update all records.
You can also find the total counter and specify it using LIMIT. But the COUNT() request does not work.
performance sql mysql sql-update limit
Happy coder
source share