141k views
1 vote
A customer maintains a high-volume data table, which holds the discounts that are applicable to products. The discount information is needed in various sections in the pricing function to calculate line item prices. It has been identified that the data table queries to fetch the discounts are significantly degrading the performance of the Commerce pricing function.

Which option will improve performance?

A. splitting the function into multiple Util library functions
B. splitting the function into multiple Commerce library functions
C. performing one BMQL query for the data table, storing the results in dictionaries, retrieving the values from the dictionaries, and using them wherever needed
D. indexing the Util library functions

User Anabella
by
7.6k points

1 Answer

6 votes

Final answer:

The best approach to improve the performance of the Commerce pricing function is to perform one BMQL query, store the results in dictionaries, and reuse them to minimize database interactions.

Step-by-step explanation:

To improve the performance of the Commerce pricing function that is significantly degraded by repeated data table queries to fetch discounts, the recommended approach is C. performing one BMQL query for the data table, storing the results in dictionaries, retrieving the values from the dictionaries, and using them wherever needed. This method reduces the number of queries made by reusing the initially fetched discount data across various sections of the pricing function, thereby minimizing database interactions.

Options A and B, which involve splitting the function into multiple library functions, may not resolve the root cause of the performance issues if the excessive querying persists. Option D, which suggests indexing the Util library functions, is not directly associated with database query optimizations. Therefore, caching the results using dictionaries allows for more efficient access to discount information and enhances overall performance.

User SergStav
by
8.3k points