113

Good question, I've never considered it before... i've just assumed the platform will play fair and I'm pleased to find it does! System.debug('Before DmlStatements : ' + Limits.getLimitDmlStatements()); System.debug('Before DmlRows : ' + Limits.getDmlRows()); insert new List<Account>(); System.debug('After DmlStatements : ' + Limits....


72

Josh Kaplan the Apex Product Manager gave quite a detailed blog post on this new governor entitled Script Limits, Begone!. In it he states this... What does this CPU timeout include? We are only counting things that require application server CPU use. For example, the time spent in the database retrieving records will not count, nor will time spent ...


43

Let's take the following SOQL: List<Account> dd = [ SELECT id, (SELECT Name FROM Contacts), // <- first subquery (SELECT AccountID FROM Cases) // <- second subquery FROM Account WHERE id IN (SELECT AccountID FROM Case) // <- not counted ]; In the above query there are total 3 ...


28

You will receive an error message when trying to save files of Error: The total size of apex code in this application after removing comments exceeds the maximum character size of 3,000,000 and the files will not submit to the server. You can contact your account executive and may be able to open a discussion to add to this limit if it is deemed ...


22

I raised a case with SalesForce to ask them the same question. After a several weeks I finally got a reply to say: We have consulted our backline team and they have confirmed that time will change as they are subjected to CPU availability. Processors naturally take a variable amount of time to process code, so it's almost never going to be the exact amount ...


20

The code in your trigger is fine. The trigger or class that the Too many SOQL queries: 101 error is thrown on may or may not be the cause of the problem. It just means that the code in question made the 101st SOQL call, which hit the SOQL limit. As the comments on your question state, the most common cause of the 101 error is that you have a SOQL query in a ...


20

As mentioned, describe limits have been removed entirely. Just for completeness, there are a few remaining limits that are affected by these describe calls, but consumption is negligible. These limits are Heap Space and CPU Time. The numbers below are for my org, so mileage will vary. I doubt the numbers would ever get high enough to be a concern. ...


19

As I have just rewritten our internal unit test design patterns I've tested this quiet thoroughly and believe I have a proper grasp on how @testSetup currently handles governing limits within the test class In short, any DML statement within the context of @testSetup will not count against your overall test class limits but SOQL statements will. For ...


18

Apex uses more resources than a simple API call, such as extra memory, CPU time, etc, so there's additional limits in place. The Developer Console, contrariwise, uses the API, which is just a server-side database cursor. As such, you can technically query up to 50,000,000 rows in the Developer Console (though very large queries may time out or freeze your ...


16

There are a number of optimizations that could occur here, but none of them are "major." Here goes. Stop Describing! This one may or may not be your main culprit, because you're not caching your describe results, potentially wasting hundreds of milliseconds in CPU time or more, depending on the quantity of record types you have. Map<String, ...


16

Yes, even though the Set<Id> accountIds is empty, 1 SOQL query will be executed and will be counted against the 100 SOQL queries limit. On a similar note, the code below won't be counted as 1 DML statement: List<Account> accounts = new List<Account>(); update accounts;


15

Yes. I have worked with Orgs where this limit has been increased. Raise a case with SF support.A few have had it increased to 6MBI am sure if you explain the steps that you have taken (cleaning up the code and checking for test methods) then this will aid your case.


15

Are the subscription triggers processed synchronously or asynchronously? Aynchronously Do the subscription triggers get separate limits from the publishing context? Yes, separate limits from the publishing context If the limits are separate, does each subscription trigger get its own set? Each Apex subscription trigger executes in its own ...


14

The API isn't the same as Apex Code. In the API, you've a hard limit of 50,000,000 rows as an administrator, and up to approximately 1,000,000 rows as a non-administrator (because of sharing calculations, depending on the object and the object's row count). The query editor is an API call, not an Apex Code call, and not subject to the limits of Apex Code. ...


14

Those two methods are slightly different: getDMLStatements() Returns the number of DML statements (such as insert, update or the database.EmptyRecycleBin method) that have been called. getLimitDMLStatements() Returns the total number of DML statements or the database.EmptyRecycleBin methods that can be called. One tells you how many DML ...


14

Be aware that the 50k limit is an overall per-transaction limit, and not a per-query limit. Do you have other code in your test method that makes SOQL queries? Are there at least 4 other queries with LIMIT 10000 in them? If so, that would do it. That things fail only in production, where you have more data, hints that this could be the case. Also, since you ...


14

Take a look at Working with Very Large SOQL Queries. Querying for field != null will hurt your performance. Typically, a custom index isn’t used in these cases. The queried values exceed the system-defined threshold. The filter operator is a negative operator such as NOT EQUAL TO (or !=), NOT CONTAINS, and NOT STARTS WITH. The CONTAINS ...


13

@RestResource annotated apex classes are just like normal apex class and only difference is they expose the apex class as a HTTP GET,POST,PUT or PATCH web-service and hence all the governor limits applicable to the apex class context apply here . These limits will be 50,000 queries in a context,150 DML,100 SOQL limit of context ,CPU limit ,Heap size limit ...


13

We can have 100 scheduled Apex jobs at one time. http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_scheduler.htm Things to consider: Scheduled APEX are like Planes. They can be on-time or little late depending on Queue. Scheduled Jobs execute as Synchronous Jobs, meaning it would get limits which are respective to Synchronous Jobs(6MB ...


13

There is a good article about pagination in Apex here: https://developer.salesforce.com/page/Paginating_Data_for_Force.com_Applications that lists various options. You have two options for pagination inside of Visualforce pages, OFFSET pagination, and StandardSetController pagination. With OFFSET pagination you are limited to 2,000 records; however, with a ...


13

Is there any limit on how many times an external systems can call Salesforce to get data? Yes, there is an API Limit as how many API calls can any external system make into Salesforce. There's a 24-hour cap on the number of API requests that can be made to an Org. The limits are reset after every 24 hour. You can find more details on the API Request Limits ...


12

Apex is a proprietary language. Other than the foce.com Eclipse plugin, there's little to no tooling available such as refactoring, code analysis, etc. True, but I could also argue that all languages are somewhat proprietary to some extent. WordPress and Joomla are both in PHP, but you can't easily port your modules and plugins between the two. ...


12

By using the Test.startTest() & Test.stopTest() you get 2X governer limits. In nutshell you have 2 context. out side of Test.startTest() & Test.stopTest() and inside of Test.startTest() & Test.stopTest(). In both context you get separate limits. To fix this issue what you will have to do is: Optimize and see if you can reduce the ...


12

After hammering the login.salesforce.com endpoints today (and getting blocked a couple of times), I've established (at least to my satisfaction) that the OAuth interactions around granting access tokens and refreshing them do not count against the API limits. More specifically, I've hit the following endpoints 1,000 times each today. https://login....


12

When the data is loaded to memory the heap size is consumed. I uploaded a book (around 1.5mb) to my org as an attachment, and then split it into several 100kb or less parts to the org's cache. Turns out the heap is consumed to store the file in memory, but when you put it into the cache, it doesn't consume more of it. // Fill in the 2mb cache with a book ...


12

Maximum size allowed is 1048576 bytes (1.05MB) When you exceed the limit, you will get below message: (Database.Error[getFields=();getMessage=The event payload size of 1179064 bytes exceeds the maximum allowed size of 1048576 bytes;getStatusCode=PAYLOAD_SIZE_EXCEEDED;]) TESTING: Create a platform event POC_PE__e and create 9 long text fields and use ...


11

You could also create you own custom apex batch queue. I did this myself and created the GitHub project SObject Work Queue which had the following design goals: Must prevent Max 5 batch in parallel limit - We should never run into this limit with work that is processed over the queue. The queue needs to be so generic that "work" on any type of database ...


11

Custom settings are cached in a special application layer cache which allows a developer to access this data without performing a query, similar to how a CPU's cache allows it to access frequently accessed information without requesting the data from main system memory. All custom settings are cached, and each record in the cache counts towards the 10MB/1MB-...


11

The system has the right to terminate any process that run longer than 10,000 ms in execution time, but it does not have the responsibility to do so. This means that during peak loads, your code might crash at 10,001 ms because the system needs to keep resources available for contending processes, but it might happily run to completion during the midnight ...


11

Try at least restricting to Account records which might match, and mapping by those values. public with sharing class LeadService { public static void findAccountsByDomain(List<Lead> newRecords) { Set<String> domains = new Set<String>(); for (Lead record : newRecords) domains.add(record.Domain__c); Map<...


Only top voted, non community-wiki answers of a minimum length are eligible