Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

Dynamics CRM 2013 - SQL Server Parameter Sniffing

Posted on by 240

Hi,

We've resolved the issue in question for the time being.

However, I'm interested if anyone else has experienced this problem and how you tried to manage the situation going forwards?

Scenario:

We have a Dynamics CRM 2013 On-Premise Installation for a customer.

The CRM Organization contains the data for 2 branches of the business, which are of very different sizes.

We have a query run by an external tool, this is run for a specific date range and for a particular value of a lookup field which indicates which branch of the business we are interested in.

  • For the branch_1, (the small one). The query will return approx 10,0000 rows.
  • For branch_2, (the big one). The query returns approx 500,000 rows

So, an order of magnitude different.

Usually the branch_1 query is run first.

This will cause a parameterised query to be created in SQL server based on the data distribution of the smaller dataset.

Then the query for branch_2 is run. The stored query plan is sub-optimal for the larger dataset.

The query takes longer than 2 minutes to execute. We get a CRM Platform Error warning on the server and a Timeout on the IOrganizationService web service call.

Solution:

We deleted the stored query plan from the SQL Server. We the query ran again, SQL Server recalculated the plan from scratch and it ran in 6 seconds!

So, that is a one-off solution to this issue.

I am interested if others of you out there in Dynamics CRM land have experienced such issues and how you manage them?

I'd be interested to hear of your experiences.

Best Regards,

Shaun

*This post is locked for comments

  • Simon Tooley Profile Picture
    Simon Tooley 60 on at
    RE: Dynamics CRM 2013 - SQL Server Parameter Sniffing

    Hi Shaun,

    We're having a similar issue with the activity wall on the account & contact pages. Did you ever find any resolution?


    Regards,
    Simon

  • David Jennaway Profile Picture
    David Jennaway 14,063 on at
    RE: Dynamics CRM 2013 - SQL Server Parameter Sniffing

    If the queries are executed via the CRM web services, you've no useful way to manage the query plans. If you do need to get to the query plan level (as it is in this case), then you really need to be retrieving data via SQL queries to get this level of control

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,235 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans