I'm working on some performance tests for my ORM.

I just noticed this with the 2010; these two queries return results.

SELECT  distinct UserId FROM Comments WHERE not UserId in (Select ID From Users) order by UserId
SELECT  distinct OwnerUserId FROM Posts WHERE not OwnerUserId in (Select ID From Users) order by OwnerUserId

Meaning I have child records pointing to non-existent users. I know Stack Overflow allows users to be deleted but shouldn't child data also have been removed. Or better, just clear the user fields and set the name to "deleted".

Now I have to make additional tests for integrity for my performance tests.

  • 5
    Whoops, sorry! Force of habit, I got thrown off by the mention of you making performance tests for your ORM. I'm getting new glasses soon!
    – Tinkeringbell Mod
    Jun 7 at 14:19

1 Answer 1


What's "the 2010"? A Stack Exchange data dump from 2010?

What you're experiencing might be caused by the backup of the Users finishing earlier than the Comments and Posts table, which are larger. If near the end of the backup a new user joins and posts something, their contribution will be in the Posts or Comments table but without a matching record in the Users table.

That is why this similar query returns results. The one blank record is actually comments by deleted users; these are now owned by Community.

  • Yeah, the StackOverflow2010. It's OK. I'll write the extra tests or change these users to -1
    – sproketboy
    Jun 8 at 13:32

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .