Skip to main content
Question

Slow SalesOrders/Tracking down source of exceptions from Request Profiler?

  • January 14, 2025
  • 4 replies
  • 67 views

Forum|alt.badge.img

Hi folks,

 

I’ve been trying to solve an issue where creating sales order via the REST API can be very slow.

 

To diagnose this issue, I enabled the request profiler and used it observe that--in addition to very large SQL counts and CPU time--the slow requests are generating exactly three exceptions per detail line: two System.InvalidCastExceptions and one PX.Objects.IN.PXUnitConversionException. Not exactly a smoking gun, but it does seem suspect to me (I don’t think we should be generating these exceptions, no?). Perhaps some data was stored in the wrong format (i.e. a string being sent where an integer is expected)?

 

Drilling down into the exception details, it looks like the source of some exceptions may be from PX.Objects.IN.PXQuantityAttribute.CalcBaseQty; but I’m not sure where to go from here. Is there a way I can determine exactly which attributes are being set? Maybe that will help me locate the offending data format mismatch. Failing that, anyone have tips for tracking down the cause of slowdowns when creating large sales orders?

 

Thanks!

4 replies

Forum|alt.badge.img+7
  • Captain II
  • January 14, 2025

What version of ACM are you running? The reason I ask is that just over a year ago I was experiencing an intermittent problem reading sales order data from ACM. Every once in a while the returned payload was filled with nulls.

The issue was fixed by upgrading to a later build of the same version. I don’t know what the exact issue was but before the update I was able to reproduce it at will and after the update it was fixed.

When you say you’re creating large sales orders, how large?


Forum|alt.badge.img
  • Author
  • Freshman II
  • January 14, 2025

Thanks for the quick response!

 

I believe we’re on version 23.213.0015.

 

The sales order I’m currently analyzing has 156 detail lines, and it took over 190 seconds to process. During that time it generated 312 InvalidCastExceptions and 156 UnitConversionExceptions.

 


Forum|alt.badge.img+7
  • Captain II
  • January 15, 2025

Out of curiosity, if you divide the number of detail lines in half, does it take half the time to import the order?  Or less than half?

Which doesn’t solve your problem or point you anywhere - I’m just wondering if 1.2 seconds per detail line is bad, slow, not great, or reasonable. I haven’t imported any orders that size.

You might also look at the json and try to make some edits to see what’s causing the exceptions that you found. Try a smaller json file along with Postman and see if you can ‘clean up’ the data to reduce those.

There’s also whatever customizations that you have in place. It is possible to make code run conditionally when importing via the API so if there is business logic running that maybe doesn’t need to when you’re pushing the order into ACM then that can save you some cycles. RowSelected is run a lot so it wants to be a tight run ship in the code where possible.

Another option could be a custom endpoint. It would allow you to accept the payload and process it more efficiently because you can make assumptions about the json data. But that’s lots of coding for someone to do so see if you can squeeze out any optimizations via the REST interface first.


Forum|alt.badge.img
  • Author
  • Freshman II
  • January 15, 2025

Thanks Django, this is extremely helpful!

 

 

Out of curiosity, if you divide the number of detail lines in half, does it take half the time to import the order?  Or less than half?

 

It appears that from ~35 to 100 items, the SalesOrder server time is roughly proportional to the number of detail lines. Somewhere between 100 and 150 lines, “seconds per detail line”-cost increases slightly (15-20%), but still tracks fairly closely.