1

I have performance issue on salesforce I am trying to load table from salesforce into excel cvs, for that used, I tested the ApexDataLoader and found out that to load whole lead table for my organization take around 4~5 min, and have around 60,000 records.

Now I want to do the same with a C# code, for that I write this code:

        var user = "xxx";
        var password = "xxx";
        var token = "xxx";
        var sforceService = new SforceService();
        var login = sforceService.login(user, String.Concat(password, token));
        sforceService.Url = login.serverUrl;
        sforceService.SessionHeaderValue = new SessionHeader { sessionId = login.sessionId };
        var query = "The full query that I took from ApexDataLoder";

        var startTime = DateTime.Now.TimeOfDay;
        var firstTime = DateTime.Now.TimeOfDay;
        var result = sforceService.query(query);
        int i = 0;
        while (!result.done)
        {
            var endTime = DateTime.Now.TimeOfDay;
            Debug.Print(endTime.Subtract(startTime) + "    " + i * result.records.Count() + " - " + (i + 1) * result.records.Count() +
                "        Time from start: " + endTime.Subtract(firstTime));
            startTime = DateTime.Now.TimeOfDay;
            result = sforceService.queryMore(result.queryLocator);

            i++;
        }

After few lines I saw that I read only 2000 lines in total (out of 60,000) in 2 miniuts.

That's mean that to get the whole table I will need 60 min.

Why there is so big difference between that ApexDataLoader (5 min) to my code? what I am doing wrong?

Thanks for the help!

Shaiba7
  • 159
  • 6

1 Answers1

0

I found 2 things that really improve performance, one, set up the EnableDecompression to true

sforceService.EnableDecompression = true;

And the second is based on this thread, it is better to do a query "select Id from Lead" and collect all the id's and then do a multi thread processing to get the data with the retrieve function.

Hope that will help people and if someone have any other improvement tricks, please let me know

Community
  • 1
  • 1
Shaiba7
  • 159
  • 6