Navision: COUNT vs. COUNTAPPROX

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.

Print | posted on Thursday, September 22, 2005 5:55 PM

Comments on this post

# re: Navision: COUNT vs. COUNTAPPROX

Requesting Gravatar...
I have one question, not connected with performance and this topic.
Is there any documentation of all standard Navision codeunits, tables and so on ??
I'm asking for code documentation - what should I use and when.
Left by SeeR on Sep 23, 2005 4:52 AM

# re: Navision: COUNT vs. COUNTAPPROX

Requesting Gravatar...
Unfortunately there's no specific documentations for all standard codeunits. However, you can find lots of useful informations on the Navision Essential, Navision Overview and Navision Application Designer's Guide pdf that you can find on your Navision set of CDs.
Left by Stefano Demiliani on Sep 23, 2005 5:51 AM

# re: Navision: COUNT vs. COUNTAPPROX

Requesting Gravatar...
Thanks, this is what I'm using now.
It's really really hard to switch to Navision enviroment from Visual Studio
:-)
Left by SeeR on Sep 23, 2005 6:55 AM

# re: Navision: COUNT vs. COUNTAPPROX

Requesting Gravatar...
I totally agree with you and I've always asked to have a better environment. Maybe with the future versions, when we'll be more "Dynamics"?
Left by Stefano Demiliani on Sep 23, 2005 7:00 AM

# re: Navision: COUNT vs. COUNTAPPROX

Left by Stefano Demiliani on Sep 23, 2005 7:37 AM

# watch replicas

Requesting Gravatar...
:P ty
Left by watches replica on Apr 29, 2010 2:55 AM

# clothing manufacturer

Requesting Gravatar...
f someone personally knows you are on a mac seems they could target you better since they know you proably won't be looking for anything out of the
Left by clothing manufacturer on Mar 06, 2011 3:37 PM

# gemstone jewelery

Requesting Gravatar...

(1908 Switzerland, Top Ten Lists China Well-known brand)4 Omega (1848 in Switzerland, top ten watches, world watch)5 Tissot watch(the world watches, China famous brand, Top Top <h2>gold name necklace</h2> Top Ten Lists)6 Swatch(world watches, Top Ten Lists, industry-leading brand)7 Citizen(Japanese brands, top ten watches, world watch)8 Rossini Watch (China famous brands, Chinese brand names,
Ten List)9 EBOHR (China Famous Brand Chinese brand names, Top Ten List)10 Fiyta Fiyta (China Well-known brands, Chinese brand names, Top Ten List) watches the the cheap costume jewelry the price difference between true and false statement days away.Remember which kind of watch You can pay for. You can go to the orignal place
see Swiss watch. You can search for google, “Swiss watch city”, where various brands of men’s watches Swiss watch the world watches. Swiss watch Swiss Swiss ladies brooches Swiss watch by the city Chamber of Commerce in China is the only designated network vendors. I hope my article useful to you.Want to buy
Left by inexpensive earrings on Apr 25, 2011 5:00 AM

Your comment:

 (will show your gravatar)
 
Please add 6 and 4 and type the answer here: