So I have a query:
AggregateResult[] results = [select max(Cash_Rewards_Number_Field__c) MaxName from Team__c];
This started causing 50001 too many rows returned errors in my trigger. When checking the debug logs, it seems as though it counted the total number of records in the team object against the query rows returned limit.
I also Tried:
List<Team__c> highestCashRewardTeam = [select Cash_Rewards_Number_Field__c from Team__c ORDER BY Cash_Rewards_Number_Field__c DESC LIMIT 1];
but the same problem arrises. Is there no way to get the max value from an object without the entirety of the objects table counting against the limit?