Page 1 of 1

Request to SalesForce takes excessive time to return result

Posted: Thu 28 Feb 2019 01:53
by tbconrad
I have a simple method call below. It passes a Loan number into the Opportunity and returns the Opportunity ID. There are 99,000+ records in the Opportunity table so not a lot but the execution of this process takes almost 7 minutes. Why the long run time? This is not acceptable when I process hundreds of records in my application daily. I tried going straight to the context (method 1) rather using the repository (method 2) but the results were insignificant in response times. I have run this against both Full Sandbox and Production with the same poor results.

Loan, is a string datatype and has been set up as a type that automatically gets indexed in the SalesForce table. Any help would be appreciated.

Code: Select all

        private string GetRelatedOpportunity(string loanNumber)
        {
            //Method 1	
            EFSalesforceContext efc = new EFSalesforceContext();
            var item = efc.Opportunities.FirstOrDefault(x => x.Loan == loanNumber);
            return item?.Id;
            
	    //Method 2
            //return loanNumber == null
            //    ? string.Empty
            //    : _sfOpportunityRepository.Find(x => x.Loan == loanNumber).FirstOrDefault()?.Id;
        }

Re: Request to SalesForce takes excessive time to return result

Posted: Wed 06 Mar 2019 20:17
by Shalex
tbconrad wrote: Thu 28 Feb 2019 01:53

Code: Select all

            var item = efc.Opportunities.FirstOrDefault(x => x.Loan == loanNumber);
Please give us the additional information:

1) enable dbMonitor and specify the generated SQL-92

2) turn on Fiddler and tell us SOQL sent to Salesforce

Re: Request to SalesForce takes excessive time to return result

Posted: Wed 06 Mar 2019 22:36
by tbconrad
It appears that the consulting firm we use for salesforce development may have may some changes. The request is down to 17 seconds per record from over 7 minutes.

Here is the Fiddler SOQL request query.

Code: Select all

SELECT Id, IsDeleted, AccountId, RecordTypeId, Name, Description, StageName, Amount, Probability, CloseDate, Type, NextStep, LeadSource, IsClosed, IsWon, ForecastCategory, ForecastCategoryName, CampaignId, HasOpportunityLineItem, Pricebook2Id, OwnerId, CreatedDate, CreatedById, LastModifiedDate, LastModifiedById, SystemModstamp, LastActivityDate, FiscalQuarter, FiscalYear, Fiscal, LastViewedDate, LastReferencedDate, SyncedQuoteId, ContractId, HasOpenActivity, HasOverdueTask, Budget_Confirmed__c, Discovery_Completed__c, ROI_Analysis_Completed__c, Approved__c, Loss_Reason__c, Bank_VOD__c, Bank_VOM__c, Bankruptcy_Date__c, Base_Loan_Amount__c, Base_Sales_Price__c, Builder_Phone__c, Builder__c, Carpet_Installed__c, Carpet_Release_Date__c, Cash_Out__c, City_Final_Date__c, CoBorrower_Assets_Jointly_Value__c, CoBorrower_Assets_Jointly__c, CoBorrower_Contact_Role__c, CoBorrower_FNM_Indicator__c, Community__c, Contract_Date__c, Current_Balance__c, Current_HOA__c, Current_Hazard_Insurance__c, Current_Lender__c, Current_Loan_Program__c, Current_Loan_Type__c, Current_Monthly_Payment__c, Current_Mortgage_Insurance__c, Current_PITI_Payment__c, Current_Property_Notes__c, Current_Property_Taxes__c, Current_Rate__c, Current_Term__c, Design_Center_Date__c, Documentation_List__c, Down_Payment_Source_List_Value__c, Down_Payment_Source_List__c, Down_Payment__c, Elevation__c, Employer_VOE__c, Estimated_Property_Value__c, First_Payment__c, Foreclosure_Shortsale_Date__c, Foreclosure_Shortsale_Value__c, Foreclosure_Shortsale__c, Fund_Sources__c, Had_Bankruptcy_in_Last_7_Years_Value__c, Had_Bankruptcy_in_Last_7_Years__c, Improvement_Cost__c, Intent_to_Proceed__c, Lien_Position_Value__c, Lien_Position__c, Loan_Application__c, Loan_Notes__c, Loan_Officer__c, Loan_Program__c, Loan_Purpose_Value__c, Loan_Purpose__c, Loan_Type_Value__c, Loan_Type__c, Loan__c, Lot__c, Marital_Status__c, Occupancy_Intend_Value__c, Occupancy_Value__c, Occupancy__c, Options_Credit__c, Options_Deposit__c, Options_Finalized_Date__c, Options_Price__c, Original_Cost__c, Own_or_Rent__c, PC_Lender_Status__c, Plan__c, Property_Address__c, Property_City__c, Property_Classification__c, Property_County__c, Property_State__c, Property_Tax__c, Property_Type_Value__c, Property_Type__c, Property_Zipcode__c, Purchase_Date__c, Purchase_Price__c, Purpose_of_Refinance_Value__c, Purpose_of_Refinance__c, Qualification_Rate__c, Rate__c, Redisclosure_CD__c, Redisclosure__c, Rental_Income__c, Requested_Close__c, Second_Mortgage_Notes__c, Second_Mortgage__c, Servicing_End__c, Servicing_Start__c, Submitted__c, Term__c, Units__c, Walk_Date__c, Year_Property_Built__c, Years_in_Line_of_Work__c, Zillow_Value__c, Sub_Source__c, Corporate_Lead__c, CLTV__c, Fee_Quote_Received__c, File_Open__c, HOA__c, Hazard_Insurance__c, Initial_Closing_Disclosure__c, Initial_Disclosure__c, LTV__c, Monthly_Payment__c, Mortgage_Insurance__c, Goals__c, Appraisal_Ordered__c, Appraisal_Received__c, Conditional_Approval__c, Contingency_Removal__c, Doc_Type__c, Docs_Back__c, Docs_Ordered__c, Docs_Out__c, Funded__c, Lender__c, Monthly_PITI_Payment__c, Sent_to_Processing__c, Setup__c, DTI_Back_End__c, DTI_Front_End__c, Lock_Date__c, Lock_Expire__c, Desired_Loan_Amount__c, Desired_Max_Payment__c, Max_Qualifying_Purchase_Price__c, Total_Funds_To_Close__c, Referred_by__c, Appraised_Value__c, Down_Payment_Source__c, DMI_Servicing_Loan__c, Clear_to_Close__c, Closed_Incomplete__c, Created_by_User__c, Stage_Status__c, Previous_Loan__c, Estimated_Close__c, Cancelled__c, Denied__c, Recorded__c, Assigned_to_Underwriter__c, Loan_Originated_Email_Sent__c, Appraisal_Received_Email_Sent__c, Assigned_to_Underwriter_Email_Sent__c, Approved_Email_Sent__c, Closed_Email_Sent__c, Borrower_s_Email__c, Recorded_Day_of_the_Week__c, Buyer_s_Agent__c, CoBorrower__c, Seller_s_Agent__c, Channel__c, Area_Manager_Created_By__c, CoBorrower2__c, Closed_Date_This_Year__c, TBD_Loan__c, Disbursement__c, Disbursement_Day_of_the_Week__c, Related_Account__c, Broker__c, Days_In_Current_Status__c, Last_PC_Lender_Status_Change__c, Opportunity_Health_Value__c, Opportunity_Health__c, Previous_Stage_Time__c, Realtor__c, Stage_Value__c, Status_Threshold_Days__c FROM Opportunity WHERE Loan__c = '370945' LIMIT 1

Re: Request to SalesForce takes excessive time to return result

Posted: Thu 07 Mar 2019 18:51
by Shalex
SOQL request is correct.

Our provider causes no performance loss in this case.

Possible reasons: slow internet connection to remote Salesforce server, high load of Salesforce server. Please contact the Salesforce Support Team for getting assistance.