Skip to main content

Questions tagged [performance]

Filter by
Sorted by
Tagged with
41 votes
4 answers
14k views

Why is Schema.describeSObjects(types) Slower Than Schema.getGlobalDescribe()?

I was about to reconfigure some of my code to use the newer Schema.describeSObjects(types) method that I had heard was faster than using a globalDescribe. I made some code to quickly check this and ...
Caspar Harmer's user avatar
1 vote
1 answer
525 views

Which one is the Optimize one when consider in a Batch?

Which one is the best way to optimize the performance if optimization available, Option 1: public without sharing class AccountTrigger extends TriggerHandler{ List<Id> accountIds; public ...
Hariprasath's user avatar
27 votes
1 answer
5k views

Dramatic increase in AsyncApexJob latency

Problem Salesforce is a multi-tenant platform and as a consequence the time for an asynchronous request to be dequeued may vary. This is not a problem for us, as long as the delays stay within ...
Sam Theisens's user avatar
18 votes
4 answers
14k views

How to avoid instantiating object inside a loop?

There are many scenarios where I have to create records of polymorphic objects using apex. For e.g. creating a Task record or a CustomObject__c record for each Case created. In general I do something ...
Jarvis's user avatar
  • 2,110
12 votes
1 answer
1k views

What's In A Hash Collision?

When I have used Custom Types in Map Keys and Sets, I generally follow a similar pattern listed in the Apex Developer Guide: public Integer hashCode() { return (31 * x) ^ y; } Someone asked ...
Adrian Larson's user avatar
  • 151k
14 votes
1 answer
3k views

Most efficient way to switch on SObjectType?

It is a bit odd we can't evaluate a switch statement directly on SObjectType, so I am trying to determine conclusively which workaround is the most efficient. Just to verify, I tried to compile this ...
Adrian Larson's user avatar
  • 151k
8 votes
1 answer
9k views

How to implement on scroll action in lightning to show next few list of records

I want to render many(about 1000) components and I am displaying them through aura:iteration in another aura:iteration. This is causing me performance issues. I want to display only 10 records at an ...
Sarang's user avatar
  • 2,655
6 votes
2 answers
3k views

Infinite queueable chaining, what is the drawback?

As mentioned here Because no limit is enforced on the depth of chained jobs, you can chain one job to another. You can repeat this process with each new child job to link it to a new child job. What ...
nSv23's user avatar
  • 554
39 votes
2 answers
4k views

Why Would I Not Enable Chaining?

The Apex Design Patterns is an awesome resource, and I learned many tricks from it. One of my favorites is method chaining, and I quickly developed an axiom: Any time you would return void, return ...
Adrian Larson's user avatar
  • 151k
25 votes
3 answers
4k views

Dealing with auto-batching of triggers

I've recently been trying to come to terms with the oddities of the auto-"batching" of triggers. What I'm referring to is how when dealing with more than 200 records in a trigger execution, ...
SFDC Neuf's user avatar
  • 1,537
24 votes
4 answers
25k views

Efficiency of List.size() > 0 vs. !List.isEmpty()

Anyone have any data to support a claim for which of the following two expressions is more efficient (meaning faster)? The use case is determining whether a List is empty to inform an auxiliary method ...
Marty C.'s user avatar
  • 4,489
17 votes
2 answers
23k views

Performance: List.get(index) vs List[index]

I want to know which approach is better in Salesforce when getting element from list. Is this faster? myList.get(0); Or is this faster? myList[0]; Using large list which above statement is more ...
Ashwani's user avatar
  • 22.6k
14 votes
1 answer
5k views

Lightning Components: why are subsequent invocations of $A.enqueueAction() so super SLOW?

I have an Lightning Component with an controller containing a sever side APEX-action like this @AuraEnabled public static Object myServerSideAction_1() { return null; } @AuraEnabled public static ...
Uwe Heim's user avatar
  • 28.5k
13 votes
1 answer
1k views

What is the performance penalty for Deterministic Platform Encryption?

Spring 18 included a beta release of deterministic encryption for the SFDC Shield Platform Encryption product. Deterministic encryption imposes fewer issues with your existing code base / metadata ...
cropredy's user avatar
  • 72.5k
13 votes
3 answers
5k views

Advice on speeding up Visualforce pages?

I have a fairly complex Visualforce page that displays about 10 fields from about 10 different custom object types including a couple of tables, making about 20 objects overall in total (i.e. 200 ...
Keith C's user avatar
  • 137k
12 votes
2 answers
2k views

How to efficiently determine the `name` field of an sobject for dynamic query?

Is there a more efficient way to determine the name field of an sobject other than iterating through all the fields obtained via DescribeSOBjectResult? Often, the name field is simply Name but in ...
Doug Ayers's user avatar
  • 4,206
12 votes
1 answer
1k views

Lightning Components: Why is the rendering of 3-level nested <aura:iteration>'s so slow?

I have been working with a nested iteration and it is causing a delay of >3 seconds AFTER loading things from the APEX controller. The APEX response itself is fast, so I'm not looking for any APEX ...
Mohamed Houssein Douici's user avatar
11 votes
3 answers
404 views

Metadata+ToolingAPI access on CS14 (and other pods) extremly slow & No Support?

We are working on CS14. Starting last Friday we are suffering form a extreme performance loss on CS14. Loading and Saving Metadata via Tooling/Metadata-API is very slow. Operations which usually ...
Uwe Heim's user avatar
  • 28.5k
10 votes
2 answers
7k views

What is the Function of aura:dependency?

I came across something that vastly improved the performance of the Lightning application that I am building. However, I am not sure exactly why. When my application initializes, I am calling a doInit ...
Daniel Fuller's user avatar
10 votes
0 answers
383 views

Make custom, in-memory "Lightning Data Service" work

Lightning Data Service is great. Multiple components are magically linked to database records. When records change in the db component show that change. Imagine this to work without saving change to ...
Robert Sösemann's user avatar
8 votes
1 answer
1k views

Iterating api variable on nested lwc is very slow

I am experiencing a weird behaviour when iterating a relatively big list in an lwc api variable when this is going through nested components. When I have two nested components the time taken to ...
sotos14's user avatar
  • 83
8 votes
1 answer
374 views

Syntactic vs Performance difference on object creation?

Is there any performance difference between: Contact con = new Contact(); con.Id = conId; con.AccountRoles__c = newRole; ... and... Contact con = new Contact( Id = conId, ...
Nathan Williams's user avatar
7 votes
1 answer
126 views

Ramifications Of Cross-Object Reference Just For Id?

The Problem I see this pattern often and it drives me crazy: Id accountId = someOpportunity.Account.Id; // just reference AccountId! OR List<MyObject__c> records = [SELECT ... FROM MyObject__c ...
Adrian Larson's user avatar
  • 151k
7 votes
1 answer
3k views

Anyone else having issues with deployment to sandbox stuck in pending for 5-60 minutes

Developing in two sandboxes and both of them when I attempt to deploy anything via metadata or tooling API the deployment is stuck in a pending status from 5-60+ minutes. I have a case open for one ...
Eric's user avatar
  • 54.3k
6 votes
2 answers
2k views

Only query Id field in start() to speed up Apex Batch

I am looking for ways to speed up a complex Batch job which takes days to run in a specific customer org. This Batch is snapshoting records of arbitrary objects into denormalized (as a single records ...
Robert Sösemann's user avatar
6 votes
7 answers
6k views

Deployment with Force.com IDE Taking Forever

We're experiencing extremely long deployment times even when deploying single classes using the force.com IDE plugin to eclipse. The deployment takes up to 1 hour yet running all unit tests from the ...
Marc's user avatar
  • 1,735
5 votes
1 answer
1k views

RemoteAction Vs REST? Which is faster?

I need to get the results really fast on my page. I have to decide between 2 approach. Build a HTTP get service, by using a VisualForce page as Service. Using contentType as 'application/JSON'. Use ...
ipradhansk's user avatar
  • 2,337
4 votes
1 answer
452 views

Formulas in workflows & validation - lazy or eager evaluated?

I tried to run some tests in developer edition and didn't see great difference so I am not sure. Basically I have a case that CPU time is leaking somewhere and I suspect it's validation rules or ...
dzh's user avatar
  • 4,165
4 votes
2 answers
248 views

EU5 not usable for development: Metadata-API deployment on EU5 unresponsive

Today I encounter a severe performance degradation on Metadata-API deployment speed on EU5. I'm waiting > 950 seconds (sometimes > 1500 seconds), when it usually deploys in < 25 seconds... This is ...
Uwe Heim's user avatar
  • 28.5k
3 votes
3 answers
12k views

Nested SOQL query?

so, the following query is pretty self explanatory: SELECT p.Accountid, p.Name, (select name FROM Account where id = p.Accountid) FROM Contact p order by accountid' is there any way to do this in a ...
gfppaste's user avatar
  • 845
2 votes
1 answer
4k views

Where can I find the Lightning Usage App?

I'm looking to use the Lightning Usage App to get metrics on my app, but I cannot find it. The Lightning Experience Performance Optimization says, "To open the Lightning Usage App, click the App ...
Chuck's user avatar
  • 1,017
0 votes
1 answer
2k views

Slow overall performance in Community

I have struggled with slow performance in my Community for years now. It is getting worse. We use a Community for our publicly facing website & for our portal. The slow performance is on all ...
Michele Kleinhomer's user avatar
39 votes
2 answers
12k views

When To Use Set vs. List In SOQL

I have always assumed that it is better to use a Set in my query filters instead of a List. For example: Set<Id> parentIds = generateParentIds(); List<Child__c> children = [SELECT Id FROM ...
Adrian Larson's user avatar
  • 151k
29 votes
3 answers
5k views

Writing too much to debug log would affect APEX trigger or Visualforce page performance?

In order to debug we usually write chunks of data to the debug log using System.debug statements. Will writing too many debug logs affect visualforce page or Apex performance in any way?
Bforce's user avatar
  • 6,858
22 votes
2 answers
9k views

What are the implications of implementing Database.Stateful?

I've recently implemented a batch apex class that initially did not implement Database.Stateful. After using it for a while as-is I decided to implemente better error handling via a simple Map to ...
ca_peterson's user avatar
  • 23.1k
19 votes
3 answers
7k views

Are sandboxes slower than production Orgs?

I've noticed quite often that sandbox instances are showing a slower performance during Metadata API and Tooling API access. Today this happened on cs14. The force.com IDE froze completely during a "...
Uwe Heim's user avatar
  • 28.5k
18 votes
2 answers
2k views

How to efficiently profile Visualforce components and their controllers?

I have a quite complex Visualforce component (edit grid) that is running to slow (2-4 seconds to display) When I say complex I mean: The Component itself is calling other components Many thousand ...
Robert Sösemann's user avatar
17 votes
4 answers
5k views

Why are foreach loops slower in Apex than standard for loop?

Considering the following test class: @IsTest private class ProfilingTest { private static String TEST_STR = ''; public static testMethod void testForEachLoop(){ List<Account> ...
Nagendra Singh's user avatar
17 votes
2 answers
874 views

Visualforce PageReference - Name Constructor vs. Factory

For a developer who wants to use a PageReference to redirect to a Visualforce Page, are there any notable differences between constructing it by name versus using the Page.PageName factory method? By ...
Adrian Larson's user avatar
  • 151k
13 votes
3 answers
2k views

Is a big startup delay for the first use of a custom Lightning App using 140 custom LWCs normal?

We have a 3rd party developed Lightning App where most of the components don't render until after a 50 second delay on the first use of the day. But you can e.g. open the Salesforce Sales app first ...
Keith C's user avatar
  • 137k
12 votes
1 answer
822 views

Why is my Lightning App inside a Managed Package extremly slow during its bootstrap phase (but not in the DEV org)?

I do have a managed package that contains a Lightning app (myApp.app) which contains various custom Lightning components. When I install the package in any org and open the app, it takes a very long ...
Christoph's user avatar
  • 1,022
11 votes
3 answers
2k views

Measuring performance of batch apex query

Is there a good way to tell how long the query in a batch apex job is taking? I don't find anything in the debug logs. I can see each batch and how long it takes, but not how long the initial query ...
mscholtz's user avatar
  • 1,334
9 votes
1 answer
2k views

Expense of using System.debug

I've seen code on an inherited project output debug info while iterating large collections of objects. System.debug(Logginglevel.DEBUG, 'sQuery=' + sQuery); If the system logging level is set ...
James Boutcher's user avatar
8 votes
1 answer
2k views

Pros and cons of generic SObject list vs multiple lists of objects

For one of the requirements I have to write code to update multiple records of different objects. Originally I was planning to do the obvious: get needed records, change some value, update these lists,...
Novarg's user avatar
  • 5,284
8 votes
4 answers
16k views

Contacts without Accounts: Is it possible, and if not, why?

Context: My understanding is that historically Salesforce was built to manage Business-to-Business (B2B) contacts, and the idea that the data model would not be built for contacts without accounts ...
blunders's user avatar
  • 1,628
8 votes
1 answer
1k views

Most optimal way to Enforce CRUD/FLS in Apex

This article shows a common way to check access in Apex with a syntax like: if (!Schema.sObjectType.Contact.fields.Name.isAccessible()){ return ''; } However, it is very time/space-consuming to ...
Jorjani's user avatar
  • 2,232
7 votes
1 answer
5k views

Suggestion to avoid for loop inside a for loop

I'm starting out new in APEX. I created below method to call inside a trigger. I know my code below is not efficient calling loop inside a loop to avoid SOQL. I looked online for a day before posting ...
NewtoApex's user avatar
6 votes
2 answers
1k views

Best practises for speeding up Apex Batch class

My previous question about slow Batches probably was to focused on a specific problem, so I try it again much broader. What are general rules of thumb to make a slow Batch faster? Although I added 2 ...
Robert Sösemann's user avatar
5 votes
1 answer
2k views

considerations re: performance and servlet.integration?

I'm assuming that servlet.integration represents the loading and launching of an apex program (VF, Controllers and all) into a java servlet runner. It appears to take a long time for the first apex ...
Kspar's user avatar
  • 151
4 votes
3 answers
3k views

Set performance - is using addAll and removeAll more performant than for loops?

I am wondering what is more performant in getting the difference between two sets: Something like this: method(Set<Id> a, Set<Id> b) { Set<Id> result = a; result.addAll(b); ...
moth's user avatar
  • 454