Note: you can use COUNTAPPROX instead of count, it is faster and was created exactly for this.
Countapprox only works differentley from COUNT if you have SQL, I think
COUNTAPPROX (Record)
Use this function to obtain an approximate count of the number of records in the table, for example, for updating progress bars or displaying informational messages.
Number := Record.COUNTAPPROX
Record
Data type: record
Refers to the table to be counted.
Number
Data type: integer
The number of records in the table.
If a filter has been set on the record, this function will behave exactly as the Record.COUNT function.
Comments
The count is approximate because it 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.
Example
This example shows how to use the COUNTAPPROX function. The statement:
Number := Customer.COUNTAPPROX;
assigns the approximate number of records in the Customer table to the Number variable.
If a filter has been set on the record, this function will behave exactly as the Record.COUNT function.
Modifying one line of code is usually not going to make much of a difference, it's repeated statements and inefficiencies in processing code that make a difference.
Most of the time, a progress bar slows down the process because of the constant updating. Executing one line of code takes almost nothing in terms of time, but for some reason repainting the dialog box does. If one of your reports is slow because of a progress bar, you need to limit the number of updates, say once every 100 updates, or only update every so many seconds.
Yes, it is true. I used to use Dialogs to in a MyDialog.UPDATE(1,MyItem."No.") - style for all data migration & repair programs just to avoid freezing finsql.exe and I found in awe that their performance bottleneck is not reading the database, but updating the dialog. Updating progress bars or dialogs just on every 100 records sounds like a good idea.
(Fun stuff: if you want to write a really _slow_ program, call COUNT on every record, updating the progress bar instead of storing the record count A coworker once did it by mistake, and later on when I corrected it the client was quite surprised that a report can be made 10 times faster with only 30 seconds of hacking )
Do It Yourself is they key. Standard code might work - your code surely works.
Another reason to follow your approch denster is to improve the performance gradually. As they do business, the database starts to grow and the reports run longer and longer, so if you make the report run slow at the beginning and gradually improve the performance, they won't complain 5 years down the road.
Ahmed Rashed Amini
Independent Consultant/Developer
I agree and the report will run at optimal, it's just you add window.update for every record, or record.count for every update, These additional functions will mimic how fast the report will run 5 or 10 years from now, and gradually you remove these functions. This whole thing was meant as joke, don't take it serously.
Ahmed Rashed Amini
Independent Consultant/Developer
Maybe we should build a dynamic performance enhancement add-on that calculates per how many records it updates the dialog depending on the number of records in the database
I agree and the report will run at optimal, it's just you add window.update for every record, or record.count for every update, These additional functions will mimic how fast the report will run 5 or 10 years from now, and gradually you remove these functions. This whole thing was meant as joke, don't take it serously.
Ah, but 5 or 10 years from now they will have upgraded to a new version of Navision, and it will be much slower then the prior version, so you will need every trick you can think of to help with speed.
I agree and the report will run at optimal, it's just you add window.update for every record, or record.count for every update, These additional functions will mimic how fast the report will run 5 or 10 years from now, and gradually you remove these functions. This whole thing was meant as joke, don't take it serously.
Ah, but 5 or 10 years from now they will have upgraded to a new version of Navision, and it will be much slower then the prior version, so you will need every trick you can think of to help with speed.
I give up. :-#
Ahmed Rashed Amini
Independent Consultant/Developer
I agree and the report will run at optimal, it's just you add window.update for every record, or record.count for every update, These additional functions will mimic how fast the report will run 5 or 10 years from now, and gradually you remove these functions. This whole thing was meant as joke, don't take it serously.
Ah, but 5 or 10 years from now they will have upgraded to a new version of Navision, and it will be much slower then the prior version, so you will need every trick you can think of to help with speed.
Using count or countapprox sux(lol Savatage). Using the updating window when running anything sux your performance dry. If you cant avoid these do only update every 1000 or 10000 records/cycles.
Comments
do the following
declare 3 variables
window of type dialog
TotalRec of type integer
CurRec of type integer
in OnPreDataItem section
window.OPEN('Processing @');
TotalRec := COUNT;
in AfterGetRecord section
CurRec := CurRec + 1;
window.Update(1,ROUND(CurRec / TotalRec * 10000,1);
in OnPostDataItem
This should do the trick
window.CLOSE;
Do It Yourself is they key. Standard code might work - your code surely works.
RIS Plus, LLC
Countapprox only works differentley from COUNT if you have SQL, I think
Most of the time, a progress bar slows down the process because of the constant updating. Executing one line of code takes almost nothing in terms of time, but for some reason repainting the dialog box does. If one of your reports is slow because of a progress bar, you need to limit the number of updates, say once every 100 updates, or only update every so many seconds.
RIS Plus, LLC
(Fun stuff: if you want to write a really _slow_ program, call COUNT on every record, updating the progress bar instead of storing the record count
Do It Yourself is they key. Standard code might work - your code surely works.
RIS Plus, LLC
Independent Consultant/Developer
blog: https://dynamicsuser.net/nav/b/ara3n
It is not something you do afterwards. [-X
This is why so many navision customers are dissapointed.
Independent Consultant/Developer
blog: https://dynamicsuser.net/nav/b/ara3n
window.Update(1,ROUND(CurRec / TotalRec * 10000,1));
1 more parentasis 8)
http://www.BiloBeauty.com
http://www.autismspeaks.org
RIS Plus, LLC
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.
I was just reading this post again - C'mon that's funny =D>
http://www.BiloBeauty.com
http://www.autismspeaks.org
I give up. :-#
Independent Consultant/Developer
blog: https://dynamicsuser.net/nav/b/ara3n
Independent Consultant/Developer
blog: https://dynamicsuser.net/nav/b/ara3n
"We just finished upgrading and now Dynamic Nav is so slow" [-o<
if CurRec MOD 10 = 0 then
window.Update(1,ROUND(CurRec / TotalRec * 10000,1));
the window is updated once every 10 records. That will save more than just a millisecond on tables with many records.
Why is it that the "Cancel" button doesn't work?
However, pressing the escape key does?
Is there an event that I need to be testing for? Or is it supposed to be handled by the dialog itself?
Thanks in advance,
Kevin
http://www.BiloBeauty.com
http://www.autismspeaks.org