# What is the governor limit for Aggregate queries and how do rows counted in AggregateResult contribute to the 50,000-row limit?

**Topic:** Soql · **Difficulty:** Medium · **Asked at:** Deloitte, PwC, Cognizant · **Tags:** soql, aggregate, governor-limits

Read it on the site: https://www.forcechallenges.com/interview-questions/what-is-the-governor-limit-for-aggregate-queries-and-how-do-rows-counted-in-aggregateresult-contribute-to-the

## Answer

Aggregate queries still count toward the shared **50,000 total retrieved rows** limit: the rows returned as `AggregateResult` objects (one per group) are counted. Also, aggregate queries can be costly because Salesforce scans the underlying records, and very large scans can time out.

Tips: add selective filters, use `LIMIT`, and verify consumption with `Limits.getQueryRows()` before and after the query in a debug test.

---
Source: ForceChallenges · last updated 2026-10-21
