3
The COUNTAPPROX statement in Navision / Business Central is one of the most useless out there today because it provides a value that is very different of the real value.
The SQL SERVER low-level implementation of COUNTAPPROX is not at all clear or non-existent in the official documentation:
https://docs.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/methods-auto/record/record-countapprox-method
Someone said this some years ago:
https://forum.mibuso.com/discussion/comment/209451/#Comment_209451
In the other side, the COUNT statement seems to LOCK the tables, either the physical Table or the Indexed View associated with the calculated fields and this makes you doubt about using it in contexts in which you are experiencing many locks in those tables with very many records.
https://vjeko.com/2017/03/09/when-you-just-must-count-no-matter-what/
My suggestion is that the low-level implementation of COUNTAPPROX does the same as COUNT does but just adding the corresponding WITH (NOLOCK) modifier to the SQL SELECT COUNT or SELECT SUM statement.
The SQL SERVER low-level implementation of COUNTAPPROX is not at all clear or non-existent in the official documentation:
https://docs.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/methods-auto/record/record-countapprox-method
Someone said this some years ago:
https://forum.mibuso.com/discussion/comment/209451/#Comment_209451
In the other side, the COUNT statement seems to LOCK the tables, either the physical Table or the Indexed View associated with the calculated fields and this makes you doubt about using it in contexts in which you are experiencing many locks in those tables with very many records.
https://vjeko.com/2017/03/09/when-you-just-must-count-no-matter-what/
My suggestion is that the low-level implementation of COUNTAPPROX does the same as COUNT does but just adding the corresponding WITH (NOLOCK) modifier to the SQL SELECT COUNT or SELECT SUM statement.
STATUS DETAILS
Completed
Business Central Team (administrator)
Best regards,
Business Central Team