I'm interested in finding the find the most efficient way to select records from a table based on a boolean attribute.
My scenario is I have a table that holds comments made by users, I want to select all the comments that are flagged as inappropriate.
The two ideas I had to implement this are:
The most logical one, have a boolean attribute 'isFlagged' in the comments table
The table would have a primary index
I would execute:
SELECT description FROM Comment WHERE isFlagged = 1;
Have a table that holds the primary keys of records from the Comment table that have been flagged
Both tables would have a primary index
I would execute:
SELECT description FROM Comment WHERE commentID IN (SELECT FK_commentID FROM FlaggedComment)
Which would execute the most efficiently?
Is there a better way to do this?