I have tables like this
# Things id user_id # ThingUser id thing_id user_id
I want to select all Things where user_id=123 OR it is related to user 123 through ThingUser.
I think maybe I'm close with something like this:
select * from things left outer join thing_users on things.id=thing_users.thing_id and thing_users.user_id = 123 where things.user_id = 123 OR thing_users.id IS NOT NULL
But on my very large dataset this hangs for several seconds and then I quit it.