Fix count cache for empty foreign keys