Is it possible to find the execution time for a DML or SOQL or SOSL? What are the factors on which the execution time of these queries depend?

  • This question is very broad and shows little research effort. Have you looked into any of the official documentation on these three separate topics? – Adrian Larson Nov 30 '17 at 3:42

Set your profiling to "finest", and you'll get items in your log that tell you how long things take.

Here's some examples from some code I wrote in Execute Anonymous:

CUMULATIVE_PROFILING AnonymousBlock: line 1, column 1: [select id from account]: executed 1 time in 27 ms

CUMULATIVE_PROFILING AnonymousBlock: line 3, column 1: Insert: Account: executed 1 time in 1001 ms

CUMULATIVE_PROFILING AnonymousBlock: line 5, column 1: [find 'test' in all fields returning account]: executed 1 time in 100 ms

To set your debug levels in the Developer Console, go to Debug > Change Log Levels. To set the debug levels in a log, you can also go to Setup > Monitoring > Debug Logs and create a new user trace.

Note that all of these different operations depend on a number of factors, including system load, system cache (recently queried records will return faster in subsequent calls), number of fields requested, complexity of filters used, number of rows found, complexity of triggers, process builder, workflow rules, validation rules, etc processed, number of rows processed for a DML statement, rollup summary calculations, the level of logging that's enabled, and more.

The debug logs can shed a lot of light on performance when you set up profiling, and by checking the profiling information, you can determine which parts are the most inefficient and work towards optimizing your configuration.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.