I have following SQL query, and it is taking long time to complete. I wanted to check if a different query can be used to achieve the same result, but could also help with performance.
Delete from table1 WHERE fk_id = '1234' AND pk_id NOT IN ('aaaa', 'bbbb', 'cccc');
Note: pk_id is PK column and fk_id is a FK for table1.
I don’t have any suggestions about the query, it’s pretty basic.
But you might want to try adding an index: