I have many tables in my database that hold information on items (Photos, Articles, Videos) that can be Liked, Disliked, Shared, Favourited etc by users.

Each time a user takes an action on a item, it is recorded in a simple table like such:

```
ItemID | UserID  | Liked | Shared | Favourited
1        1         NULL    1        NULL
2        25        1       1        1
3        18        0       NULL     NULL

```

When I'm writing a query to return a list of items from a table (e.g. Photos) I also want to return the total number of Likes, Shares etc each item has. At the moment I'm calculating this on the fly using a nested SELECT statement. If my item tables grow in size by hundreds of thousands, and I constantly need stats on Likes, Shares etc, then would it be safe to continue calculating stats on the fly or should they be stored as totals somewhere in the database?