I have this query:
UPDATE invitations SET added=added+1 WHERE chat_id NOT IN (SELECT * FROM (SELECT LEFT(name,14) AS chat_id FROM rules WHERE name LIKE '-%-credit' AND value< 1522744396) AS iner)
every time I execute it it takes like ages and it never does what i want it to do. for example I have run it now and it has taken 1600 seconds so far and nothing happened yet. In show proccesslist I see that it's in the State of "Sending data". What's wrong with this query?
The table rules has at most 100K rows and the inner query returns like 2K rows. the results of the inner query are one column and are like: chat_id -1001167043635 -1001167043643 ...
when I run the inner query alone, it takes like 0.007 seconds.
And the invitations table has 500K rows and are like: user_id | chat_id | added 55545323 | -1001167043635 | 23
it would be appreciated if you tell me what i have done wrong and tell me how to fix it.