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

13 lines
No EOL
631 B
Markdown

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