0

How many records might get fetched from Database in single context using two SOQL queries ?

1 Answer 1

2

http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_gov_limits.htm

At the moment - 50K in total. This might be limited further for example if you'll query large textarea fields and run out of heap size before running out of query rows.

Also if Integer c = [SELECT COUNT() FROM Account]; returns "N" as result it means you've wasted N rows, not one as you might expect from other SQL languages (COUNT looks like it's returning only 1 row, right?)

Don't hardcode 50000 in your application, use Limits class. Limits.getLimitQueryRows()

2
  • suppose i have 2 SOQL queries in single context then how many records i can fetch from both the queries?
    – Pankaj
    Commented Mar 5, 2013 at 9:47
  • 1
    I thought I've answered? No more than 50000 in total. For example 10000 in first query, 40000 in second one is fine. If you have less data returned - no problem. The moment you'll try to retrieve the row 50001 you'll get an un-catchable governor limit exception and whole transaction will be rolled back. Maybe it will be better to know why are you asking this question to help you better.
    – eyescream
    Commented Mar 5, 2013 at 9:55

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .