How to determine which `Foos` have no associated `Bars`
There are probably bars that have NULL in foo_id.

select 1 where 55 not in (select 1 union all select null)


The above query returns 0 rows.

The solution is to change the query to use NOT EXISTS instead of NOT IN as follows:

select * from foos f where not exists(select * from bars b where b.foo_id = f.id)


Not only is this safer as you don't have to manually exclude NULLs from the subquery, but also this construct will generally provide better performance. So for the most part, I recommend getting into a habit of doing it this way instead of using NOT IN.