Part 13 - Update Performance for Simple Entities

What can we learn about update performance from simple entities?

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

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. To help draw out our datapoints, we will be using a version of the SalesOrderHeaderV2 data entity that has all references to all tables that are not SalesTables removed. This entity exposed table SalesTable with nearly no business logic built into it.

"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.

                DataServiceCollection<SalesOrderHeaderV2EntityOnlySalesTable> SalesOrderCollection = new DataServiceCollection<SalesOrderHeaderV2EntityOnlySalesTable>(context);
                string salesURL = SalesOrderHeadersV2EntityOnlySalesTable.URL;

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

                SalesOrderCollection.Add(SalesOrderHeadersV2EntityOnlySalesTable);

                SalesOrderHeadersV2EntityOnlySalesTable.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..

                DataServiceCollection<SalesOrderHeaderV2EntityOnlySalesTable> SalesOrderCollection = new DataServiceCollection<SalesOrderHeaderV2EntityOnlySalesTable>(context);
                string salesURL = SalesOrderHeadersV2EntityOnlySalesTable.URL;
                string customerReference = SalesOrderHeadersV2EntityOnlySalesTable.CustomersOrderReference;
                string DeliveryAddressName = SalesOrderHeadersV2EntityOnlySalesTable.DeliveryAddressName;
                string SalesorderName = SalesOrderHeadersV2EntityOnlySalesTable.SalesOrderName;

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

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

                SalesOrderHeadersV2EntityOnlySalesTable.URL = salesURL;
                SalesOrderHeadersV2EntityOnlySalesTable.CustomersOrderReference = customerReference;
                SalesOrderHeadersV2EntityOnlySalesTable.DeliveryAddressName = DeliveryAddressName;
                SalesOrderHeadersV2EntityOnlySalesTable.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 161 ms across 100 tests while the maximum test averaged 663 ms.

TL;DR and Key Takeaways

  • Less data specified means better performance
  • Less complex entities perform better than complex entities
  • Test and review based on your specific needs

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