Print this page

Deployment running slow

Knowledge Article Number 000002478
Description

If you're experiencing performance issues when deploying to production, remember that all tests are being run before any code can be deployed and this could affect performance. While there isn't a specific reason for slow deployment speed. Several factors can influence the performance such as class complexity & query performance.

Resolution

1. Look at optimizing queries, always have a where clause and make sure you're looking at a relatively small subset of the data.
2. In your test classes: Try to use objects rather than queries.

For example:
Say you need a list of accounts from toronto –
Rather than doing:

Account acc = [Select name from Account where site=’Toronto’];
 

Try do the following:  

List<Account> accList = new List<Account>();

                Account acc;

                For (int i=0 ; i<10 ; i++) {

Acc = new Account();

Acc.name = ‘test’;

Acc.site = ‘Toronto’;

AccList.add(acc);

}
 

3. Batch classes: Testing those could be slow.  If you have batch classes – you’d know that these have a “startTest” and “stopTest” methods. Rather than having a single test class for each of the batch classes – I’d recommend you use a single startTest/stopTest methods for ALL batch classes.
4.  Rather than creating new objects everytime you require one in your test classes, create a static class with the sole purpose of instantiating objects. i.e. with methods such as “getNewAccount()” etc.





promote demote