Take the 2-minute tour ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

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

closed as not constructive by ypercube, RolandoMySQLDBA, Derek Downey, Leigh Riffel, Phil Oct 19 '12 at 14:00

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.If this question can be reworded to fit the rules in the help center, please edit the question.

    
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 '12 at 10:15
    
possible duplicate of query optimization for update nested query IN(SELECT –  ypercube Sep 14 '12 at 10:46
add comment

1 Answer 1

Add composite indexes to your tables:

On COLOR_TAGS, index (COLOR_PROJECTID, NoteID)

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

share|improve this answer
add comment

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