Dataverse Plug-in Performance: Reduce Service Calls and Keep Transactions Short

Synchronous plug-ins execute in the request pipeline and can affect user-facing latency. Performance improves when code retrieves only required columns, avoids repeated calls and limits expensive work inside the transaction.

Overview

Improve Dataverse plug-in performance by limiting Retrieve and RetrieveMultiple calls, minimizing payloads and keeping synchronous transaction work short.

Implementation steps

  1. Profile the plug-in path and identify the number of service calls and the columns retrieved.
  2. Use Target and registered entity images when they already contain the values needed for the business rule.
  3. Use narrow ColumnSet definitions rather than retrieving all columns.
  4. Avoid synchronous external HTTP calls and move long-running integration work to an asynchronous or event-driven design where appropriate.
  5. Review recursion, query selectivity and plug-in registration so the code runs only when needed.

Example

// Retrieve only required columns
var account = service.Retrieve(
    "account",
    accountId,
    new ColumnSet("name", "accountnumber", "statecode"));

// Prefer a narrow query over ColumnSet(true)
var query = new QueryExpression("contact")
{
    ColumnSet = new ColumnSet("contactid", "fullname"),
    TopCount = 50
};

Common pitfalls

  • Do not use ColumnSet(true) for convenience in a hot path.
  • Avoid external network calls in synchronous transactions.
  • Do not optimize blindly; measure execution time and service-call count first.

Validation checklist

Compare trace timings before and after changes, test high-volume operations and confirm business logic remains correct.

Conclusion

Adopt a measured rollout, monitor the real workload and make recovery part of the design. Reliable production systems depend on tested operational practices as much as on working code.