If your site uses promotions that require unique promotion codes, the generation, or
import of these codes can affect performance. Generating, or importing millions of unique promotion
codes when you are working on approved content can result in a reduction in performance. You can
reduce the effect on performance when you generate or import codes by using batch updates to insert
the codes into the database.
When you generate millions of unique promotion codes consider the following promotion
code generation behavior:
- This size of the batch of promotion codes to delete. When the generation of promotion codes is
canceled while in progress, the codes created before the cancellation must be deleted. If there is
no batch size that is set for deleting promotion codes, all of the created codes are deleted in a
single batch. Depending on the size of this batch, the delete process can fail or take a significant
amount of time to complete. There is a
CodeDeleteBatchSize
configuration property
available for setting the batch size for how many codes are to be deleted at a time. This property
has a default value of "1000" and can be found in the promotion component
wc-admin-component.xml configuration file.
- The size of the batch of promotion codes to populate. When you generate or import millions of
unique promotion codes, consider setting a higher value for this flag, for example "100,000". The
CodePopulateBatchSize
configuration property is used to control how many promotion
codes are generated and inserted into the database in each batch. This property has a default value
of "1000" and can be found in the promotion component wc-admin-component.xml
configuration file.
- The ratio of codes to generate versus the maximum number of possible codes that are supported by
the pattern. Create promotions with a ratio of at least 1:20 for the number of codes to generate
versus the maximum number of possible codes. This ratio ensures that the logic for promotion code
generation does not generate the same code repeatedly and helps to improve overall performance.
- The uniqueness of promotion codes that are being populated. Ensure code uniqueness by using
prefixes and suffixes. If your store has many promotions that use unique promotion codes, consider
specifying a unique prefix or suffix, or both, for each promotion. These prefixes and suffixes
ensure that a unique set of promotion codes is generated and no conflicts are found with existing
codes in the database. For details on prefixes and suffixes, see simple system-generated
unique promotion codes or advanced
system-generated unique promotion codes.
- The unique promotion code scheduled job that generates codes can be configured. You can
configure this job to run on a particular host, with a particular application type, or with a
specific priority. New configuration settings can be made for
HostForPromotionCodePopulationScheduledJob
,
ApplicationTypeForPromotionCodePopulationScheduledJob
, and
PriorityForPromotionCodePopulationScheduledJob
in the promotion component
configuration file, wc-admin-component.xml.