You need to sign in to do that
Don't have an account?
Issue System.LimitException : Too many query rows : 50001(very very urgent)
I have 45,000 Records in Transaction Object.
I am running two 'group by' queries on Transaction Object.
Follwing are the queries.
Aggregations:0|select max(id) id1, Max(CnP_PaaS__CnP_Account_ID__c) ClickAndPledgeAccountName,Max(CnP_PaaS__CnPAccountID__c) ClickAndPledgeAccountId,Max(CnP_PaaS__Contact__r.Email) ContactEmail,CnP_PaaS__Contact__r.Name ContactName from CnP_PaaS__CnP_Transaction__c where id!=null and (CnP_PaaS__Application_Name__c=:appname or CnP_PaaS__Application_Name__c=null) and CnP_PaaS__TransactionTimeZone__c != Null Group by CnP_PaaS__Contact__r.Name
Rows:1256
Aggregations:0|select max(id) id1, Max(CnP_PaaS__CnP_Account_ID__c) ClickAndPledgeAccountName,Max(CnP_PaaS__CnPAccountID__c) ClickAndPledgeAccountId,Max(CnP_PaaS__Contact__r.Email) ContactEmail,CnP_PaaS__Contact__r.Name ContactName from CnP_PaaS__CnP_Transaction__c where id!=null and (CnP_PaaS__Application_Name__c=:appname or CnP_PaaS__Application_Name__c=null) and CnP_PaaS__TransactionTimeZone__c != Null Group by CnP_PaaS__Contact__r.Name limit 400
Rows:400
when i am running these queries i am getting an exception.
"Too many query rows: 50001"
So, What is the solution for this.
hi,
Use Limit
for example:
Public static integer getTotalVotes()
{
];
return totalIdea ;
}
I am using LIMIT in My soql Query.
still I am getting that.
Thanks for Respnse
see those queries block going in to an infinite block ....may be the same class or method is invoking multiple times in the same process
Thanks for ur reply,
I Have a confusion on soql query with group by option.
How will the soql query run on the database.
I have 197,595 records on contact object.
i am running this query like 'select name from contact where name!='' group by name limit 10000
it is returning 10,000
but in limits it is showing Number of query rows: 19234 out of 50000
y it is giving 19234
r u using dynamic soql if not can you please try
select name from contact where name!= null and check
hi kiran,
Yes i am building dynamic soql. The requirement is that. i really don't know why it is returning all the records. plz explain me if u have any idea
Thanks
One thing I noticed a while ago is that it is likely not returning all the rows. When you use dynamic SOQL, SFDC looks at the query and decides whether it "could" return too many records. If if "could" return too many, you get the error. The determination is based on whether the SOQL query is "selective" Here is an entry page on the topic: http://www.salesforce.com/us/developer/docs/apexcode/Content/langCon_apex_SOQL_VLSQ.htm
Success,
JeffM
Hi,
If you use Group By in your query, you actually select the distinct name from your contact object.
And the reason query rows showed a different number than what you've specified at your LIMIT keyword was because the query rows counted any records that were included in the aggregation, not just the number of rows returned by the query.
Could you give us a bit of background of your query, and maybe some codes as well so we can take a look?
-Hengky-