Can the following query be optimized ?

DELETE FROM COLOR_TAGS 
WHERE COLOR_PROJECTID = $id 
AND NoteID IN(
SELECT ID FROM note_note 
WHERE BibID=$bid AND isdel=0);
share|improve this question

0% accept rate
Is it suboptimal? If yes, how? Please, make your questions a bit more meaningful by adding detail. If you don't provide us with details, the best answer is 'Probably yes/no'. Until then, I place a -1 vote. – dezso Sep 14 at 10:15
possible duplicate of query optimization for update nested query IN(SELECT – ypercube Sep 14 at 10:46
feedback

1 Answer

Add composite indexes to your tables:

On COLOR_TAGS, index (COLOR_PROJECTID, NoteID)

On note_note, index (isdel, BibID, ID).

share|improve this answer
feedback

Your Answer

 
or
required, but never shown
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.