Part 12 - Update Performance for Complicated Entities

What can we learn about update performance from complicated entities?

Similar to how we tested insert performance for complicated entities, we're going to run similar tests to see what kind of performance we can expect with an update workload.

The Tests

To draw out values and differences, we'll be testing with 2 basic test types: "Minimum" and "Maximum", just like we have in the past. What we're trying to draw out is the performance difference between updating a record with a small amount of attributes specified and quite a few attributes specified. Does the distinction matter or not so much? We'll be using the Sales Orer Header V2 entity for both tests to see how data can change performance. This is a distinct test as we'll be measuring performance of the update operation only, not the find operation for the entity.

"Minimum" Test

In this test, we'll be specifying just 1 value to go through the smallest update operation we could simular. We are setting a simple string on the Sales Order Header that has no specific functionality behind it so this test is as simple as we can create.

                // replace whatever is there with this trash
                salesURL = "http://www." + Guid.NewGuid().ToString() + ".com";

                SalesOrderCollection.Add(SalesOrderHeaderV2);

                SalesOrderHeaderV2.URL = salesURL;

                context.SaveChanges(SaveChangesOptions.PostOnlySetProperties | SaveChangesOptions.BatchWithSingleChangeset);

"Maximum" Test

In this test, we'll be specifying quite a few more values and also setting values on an entity embedded in our test entity..

                // replace whatever is there with this trash
                salesURL = "http://www." + Guid.NewGuid().ToString() + ".com";
                customerReference = Guid.NewGuid().ToString();
                DeliveryAddressName = Guid.NewGuid().ToString();
                DeliveryAddressDescription = Guid.NewGuid().ToString();
                SalesorderName = Guid.NewGuid().ToString();

                sw.Start();
                SalesOrderCollection.Add(SalesOrderHeaderV2);

                SalesOrderHeaderV2.URL = salesURL;
                SalesOrderHeaderV2.CustomersOrderReference = customerReference;
                SalesOrderHeaderV2.DeliveryAddressName = DeliveryAddressName;
                SalesOrderHeaderV2.DeliveryAddressDescription = DeliveryAddressDescription;
                SalesOrderHeaderV2.SalesOrderName = SalesorderName;

                context.SaveChanges(SaveChangesOptions.PostOnlySetProperties | SaveChangesOptions.BatchWithSingleChangeset);

The Results

Reviewing the graph below, we can see that the "minimum" test have an average of 411 ms across 100 tests while the maximum test averaged 1821 ms.

TL;DR and Key Takeaways

  • Less data specified means better performance
  • Amount of data loosely scales to the time it takes to persist that data
  • Pay attention to entities nested in entity for performance

All code can be found at https://github.com/NathanClouseAX/AAXDataEntityPerfTest/tree/main/Projects/AAXDataEntityPerfTest/Part12 and data can be found at https://github.com/NathanClouseAX/AAXDataEntityPerfTest/tree/main/Projects/AAXDataEntityPerfTest/Part12/Analytics.