I have an administration panel and in it I display all the users, with a line that mentions how many photos he has posted.

By default I have a seeder that imports 17,000 photos and the user who posts them is an administrator, so I have 1 user who has 17,000 photos.

In this panel, I display this count:

```
{{ $user->pictures()->count() }}

```

However with the debug bar I see that it takes a lot of time (300ms), here is the query with the debug bar:

```
select count(*) as aggregate from `pictures` where `pictures`.`user_id` = 'fe9eaf79-fc2d-47b8-8a43-4c61a81bce22' and `pictures`.`user_id` is not null and `status` = 1 and `pictures`.`deleted_at` is null

```

In the controller, I've this :

```
public function show()
    {
        $users = User::orderBy('username', 'ASC')
            ->paginate(20);

        return view('admin.users', [
            'users' => $users,
        ]);
    }

```

Do you know how I can optimize this count on such a big table?