1
0
Fork 0
mirror of https://github.com/archtechx/laravel-tips.git synced 2025-12-12 13:24:03 +00:00
laravel-tips/content/tips/you-can-calculate-multiple-aggregates-in-a-single-database-query.md
2021-12-10 16:25:33 +01:00

631 B
Raw Permalink Blame History

title tweet_id thread_slug author_username images created_at slug
You can calculate multiple aggregates in a single database query 1469321061955108864 weekly-thread-2021-49 tobias_petry
https://pbs.twimg.com/media/FF5qzyXXwAc445P.jpg
2021-12-10T15:00:14+00:00 you-can-calculate-multiple-aggregates-in-a-single-database-query

Database Tip

You don't have to execute multiple queries to calculate different aggregates. With the filter clause you can narrow the rows which should be included for the calculation. So you may need to scan the table only once, the performance impact can be massive 🔥