I don't think it has any relevance here, but bear in mind the correct query would be:
[code]SELECT * FROM xengallery_comment WHERE content_id = 3 AND content_type = 'media'[/CODE]
The code for the rebuild process really isn't very complicated.
It goes through batches of media items, it counts the number of comments (it only counts comments that match the media id, content type is media and are visible), then regardless of whether it has changed or not, it sets the comment_count field in the xengallery_media table to that count using the Media DataWriter.
If running this query:
[CODE]SELECT COUNT(*) FROM xengallery_comment WHERE content_id = 3 AND content_type = 'media'[/CODE]
Returns the correct count (e.g. 1 based on what you said above) then there's nothing in the code that would set it to anything different.
Out of interest, what does this query return?
[CODE]SELECT comment_count FROM xengallery_media WHERE media_id = 3[/CODE]