Skip to main content

What can go wrong with number sequences?

  • Very low performance of the application

  • Data base blocking on the number sequence table so al user get stocked when the need a sequence number.

  • Let’s start with the worst performance setup related to a number sequence. We set the customer account number on continues. The below table shows the queries that are executed.


    Continues = true, pre allocation = false
    First time (8 database calls)
    SQL statement: (SysRecordTemplateTable)

    SQL statement: (CustFormletterParameters)

    SQL statement: (NumberSequenceReference)

    SQL statement: (NumberSequenceTable)

    SQL statement: (NumberSequenceTable)

    SQL statement: (NumberSequenceList)

    SQL statement: (NumberSequenceList)

    SQL statement: (NumberSequenceTable)
    Second time (5 database calls)
    SQL statement: (NumberSequenceTable)

    SQL statement: (NumberSequenceTable)

    SQL statement: (NumberSequenceList)

    SQL statement: (NumberSequenceList)

    SQL statement: (NumberSequenceTable
    )



Now we remove the Continues option and create a new customer. We see that less sql statements are executed.



Continues = false, pre allocation = false
First time (7 database calls)
SQL statement: (SysRecordTemplateTable)

SQL statement: (CompanyInfo)

SQL statement: (CustFormletterParameters)

SQL statement: (NumberSequenceReference)

SQL statement: (NumberSequenceTable)

|SQL statement: (NumberSequenceTable)

SQL statement: (NumberSequenceTable)
Second time (2 database calls)
SQL statement: (NumberSequenceTable)

SQL statement: (NumberSequenceTable)








Now we remove the Continues option and allow Pre allocation (caching). We see almost no more sequence related SQL statements:








Continues = false, pre allocation = true
First Time (6 database calls)
SQL statement: (SysRecordTemplateTable)

SQL statement: (CustFormletterParameters)

SQL statement: (NumberSequenceReference)

SQL statement: (NumberSequenceTable)

SQL statement: (NumberSequenceTable)

SQL statement: (NumberSequenceTable)
Second Time (1 database call)
SQL statement: (NumberSequenceTable)






Also removing the format of the sequence will improve the speed. (If you Look at the class NumberSeq::numInsertFormat(), you can see how the filter is used. Because this code uses a lot of loops and string searches, it decrees the speed a lot)




Best practice:


Only use continues number sequences when there is really no alternative. Also inform the customer about the performance impact.


Situations where continues number sequences are often use.


ÿ Documents that leave Axapta. (sales order, purchase orders, etc)
ÿ When the law of the country does not allow interrupts in the voucher series. (When interruption occur, explanation is needed)

Continuous Number Sequences

Continuous number sequences can only be used in transactions (TTSBegin & TTSCommit)

When you use continues number sequences without TTS the following message appear:

System does not support setup 'continuous' of number sequence ‘sequence name’.

This can be solved by un checking continuous or add TTS transactions in the code.

Popular posts from this blog

Mark All for Open Cust Trans and Open Vend Trans

We have situations where there are lots of open transactions that need to be settled against each other. This can be the case if auto settlement is turned off. One solution is to add a "Mark All" button to the custOpenTrans or vendOpenTrans forms. This button "checks" the mark checkbox on every line. The user can then uncheck several lines if needed and Update to settle the lines. The code below is an example of what we used on the open vendor transaction screen. The code is very similar on the AR side. One note: I used vendTable.AccountNum in the code below. That should be generalized to work with any buffer that is passed into the open trans form. void customMarkAll() { VendTransOpen localVendTransOpen; VendTrans localVendTrans; container conSum; int linesProcessed; ; //show wait cursor startLengthyOperation(); element.lock(); //remove all prior markings specOffsetVoucher.deleteSpe...

Print Report in Microsoft Dynamics AX 2009 through X++

I am trying to print sales confirmation report on a button click which I have added on Sales Order Detail form in Microsoft Dynamics AX 2009. On click event of that button, I have written following code: void clicked() {     Args                args;     ReportRun           reportRun;     SalesFormLetter     salesFormLetter;     PrintJobSettings    printJobSettings;     CustConfirmJour     custConfirmJour;     RecordSortedList    list                = new RecordSortedList(55);     SalesTable          salesTableUpdate;     ;     SELEC...

Creating Free Text Invoice through X++ code

Job: Calling class from job to run the class public void freeTextInvoicePostTestJob() { Dialog dialog; DialogField dlgCustAcc; DialogGroup dialogPeriodLengthGroup, dialogPeriodLengthGroup1; DialogField dlgLedgerAcc; ; dialog = new Dialog("Free-Text Invoice"); dialogPeriodLengthGroup1 = dialog.addGroup('Cust Table'); dlgCustAcc = dialog.addField(typeid(CustAccount)); dialogPeriodLengthGroup = dialog.addGroup('Ledger Table'); dlgLedgerAcc = dialog.addField(typeid(LedgerAccount)); if(dialog.run()) { if(dlgCustAcc.value() && dlgLedgerAcc.value() != '') FreeTxtInvoiceCreatePost::main(dlgCustAcc.value(), dlgLedgerAcc.value()); else throw error(strfmt("Either CustAccount or LedgerAccount info is missing.")); } } Class: Which creates the free text invoice class FreeTxtInvoiceCreatePost { } static void main(CustAccount _custAccount, LedgerAccount _ledgerAccount) { CustInvoiceTable custInvoiceTable; ...