# Performance considerations for the best deal feature

The best deal feature provides a way to ensure that your customers get the best deal possible when their order qualifies for multiple promotions in the same promotion group with the same priority. There is, however, a performance cost for the feature because the promotion engine must evaluate a potentially large number of sequence combinations to determine the best deal. To manage performance impacts, you can raise or lower the default upper limit for the number of sequence evaluations per order.

## Determining an appropriate sequence combination limit for your store

By default, the best deal feature is configured to allow 50 sequence combinations per order. When this limit is reached, the promotion engine stops evaluating sequence combinations and selects the best deal from among the sequence combinations that are evaluated. If the limit is set too low for your store, then certain orders might not get the best possible deal. If the limit is set too high, then your store might experience performance problems.

Estimate how many sequence combinations the promotion engine might need to evaluate to apply the best deal feature to a customer’s order on your storefront. You can then set an appropriate sequence combination limit that is based on your estimate to minimize performance impacts of the feature.

Use the following worksheet to gather the relevant data from the Marketing Manager for your store. Then, plug the data into the following formula to estimate the potential number of sequence combinations for your store.

Worksheet to gather best deal promotion data from Marketing Manager
How many promotion sets does the store typically have active on the storefront at the same time?

Definition of a promotion set: two or more promotions within the same promotion group that are assigned the same priority.

Number of sets: _____

For each set, how many promotions are in the set?

Set 1: _____ (S1)

Set 2: _____ (S2)

Set 3: _____ (S3)

Set 4: _____ (S4)

Set 5: _____ (S5)

Set n: _____ (Sn)

To estimate the potential number of sequence combinations for your store, plug the data from the worksheet into the following formula:
``(S1)! x (S2)! x (S3)! x (S4)! x (S5)! x … (Sn)! = possible sequence combinations``
Example: Consider a store that has two promotion sets:
• Set 1: Two order-level promotions with a priority of 100
• Set 2: Four catalog-entry-level promotions with a priority of 100
The completed worksheet can look like the following table:
How many promotion sets does the store typically have active on the storefront at the same time?

Definition of a promotion set: two or more promotions within the same promotion group that are assigned the same priority.

Number of sets: 2

For each set, how many promotions are in the set?

Set 1: 2

Set 2: 4

Using the formula, the estimated potential number of sequence combinations for your store is: 2! x 4! = 2 x 24 = 48 possible sequence combinations. Based on this example, an appropriate sequence combination limit might be 48.

## Restricting promotion groups and promotions for promotion groups

You can improve the performance of the Promotion Engine when it is evaluating the best deal logic by restricting which promotion groups are processed with the best deal logic. The Promotion Engine can also be configured to restrict the number of promotions that are processed for each promotion group with the best deal logic. Restricting the number of promotions to be considered for each promotion group can improve the performance of processing with the best deal logic.

If you do not configure the best deal logic to restrict the number of promotions per promotion group and the number of promotions, all promotions per promotion group and all promotion groups use the best deal logic. You can restrict these promotions and promotion groups by changing the following configuration flags in the WCSPromotionEngineConfig.xml file:
PromotionGroupsForBestDealEvaluation
This flag contains a comma-separated list of promotion groups that are used in the best deal evaluation. If no promotions groups are configured, then all promotion groups are used when the Promotion Engine evaluates the best deal.
MaxPromotionsPerGroupForBestDealEvaluation
The maximum number of promotions per group that are used when the Promotion Engine evaluates best deal. If no maximum value is set, then there is no limit on the number of promotions per group that are used in the best deal evaluation.
SequenceCombinationLimit
The maximum number of best deal combinations to use in the best deal evaluation.
Consider the following guidelines when you configure the best deal support.
• Keep the maximum configuration to 5 deals per group (`MaxPromotionsPerGroupForBestDealEvaluation`) and 120 combinations total (`SequenceCombinationLimit`), or 6 deals per group and 720 combinations total.
• Keep the total number of combinations (`SequenceCombinationLimit`) equal to or less than the factorial of the number of promotions per group being considered (`MaxPromotionsPerGroupForBestDealEvaluation`).
The following code in bold demonstrates how to change the configuration of these flags to restrict the maximum number of promotions per group to 3 promotions, and restrict the number of promotion groups to include only order level promotions:
``````<DefaultBehavior>
<StatelessInvocation>true</StatelessInvocation>
<CheckTargetingAtRuntime>true</CheckTargetingAtRuntime>
<SkipTargetingOnCodeEntered>true</SkipTargetingOnCodeEntered>