Sometimes I see on Navision's code that developers retrieve
the number of records in a table by using the COUNT instruction.
This is correct, you can retrieve the number of records you have in a table
by doing like this:
Customer.SETRANGE(........) //Apply a filter to the
Customer table
Total := Customer.COUNT;
But if you want to retrieve the number of records only to perform
actions like simple calculations, progress bar update etc., for performance
reason it's better to use the code below:
Customer.SETRANGE(........) //Apply a filter to the
Customer table
Total := Customer.COUNTAPPROX;
Here, the record count is approximate because the COUNTAPPROX instruction uses statistical information
maintained by SQL Server, which is not kept precisely in synchronization with
modifications to the table and is not under transaction control. However, it is
much faster to use this information than to perform an accurate record count
under transaction control, especially when there is a large number of records in
the table.
Navision development (expecially under SQL Server) needs a lot of work for
increase performances and this is one of the tips you've always to remember.
