Use DB at 100% without filling the COMMIT-cache

kriki
Member, Moderator Posts: 9,121
NATIVE DB-ONLY!!!
The following code can be used to fully occupy the DB, but without filling the COMMIT-cache and blocking other users.
Use function "PerformanceSleep()" just after a COMMIT in your code. This function can be used in SQL without receiving an error-message, but will not do anything.
The following code can be used to fully occupy the DB, but without filling the COMMIT-cache and blocking other users.
Use function "PerformanceSleep()" just after a COMMIT in your code. This function can be used in SQL without receiving an error-message, but will not do anything.
PerformanceIndication() : Integer // PerformanceIndication // gives an indication of the performance of the server // IMPORTANT : NOT usable with SQL-server // PARAMETERS // RETURN-VALUE : indication of performance of the server // 0 : the server is doing (almost) nothing // 1 : no performance problems, but can become bad very fast // 2 : no performance problems, but system is very busy // 3 : performance problems very likely // ex : writing of thousands of records in multiple transactions // every few records : do this test // FOR i := 1 TO 100000 DO BEGIN // write record; // IF i MOD 200 THEN BEGIN // COMMIT; // CASE PerformanceIndication() OF // 0 : BEGIN END; // 1 : SLEEP(1000); // 1 second // 2 : SLEEP(5000); // 5 seconds // ELSE BEGIN // j := 0; // WHILE j < 3 DO BEGIN // wait until performance is ok, or until 1/2 minute has passed // SLEEP(10000); // j := j + 1; // IF PerformanceIndication() < 3 THEN // j := 3; // END; // END; // END; // END; LintTestDiskAccess := 0; LrecDatabaseFile.RESET; LrecDatabaseFile.SETCURRENTKEY("No."); IF LrecDatabaseFile.FIND('-') THEN REPEAT IF (LrecDatabaseFile."Writes in Queue" >= 5000) OR (LrecDatabaseFile."Reads in Queue" >= 16) THEN BEGIN LintTestDiskAccess := 3; END ELSE IF (LrecDatabaseFile."Writes in Queue" >= 2000) OR (LrecDatabaseFile."Reads in Queue" >= 7) THEN BEGIN IF LintTestDiskAccess < 2 THEN LintTestDiskAccess := 2; END ELSE IF (LrecDatabaseFile."Writes in Queue" >= 500) OR (LrecDatabaseFile."Reads in Queue" >= 3) THEN BEGIN IF LintTestDiskAccess < 1 THEN LintTestDiskAccess := 1; END; UNTIL LrecDatabaseFile.NEXT = 0; EXIT(LintTestDiskAccess); PerformanceSleep() // PerformanceSleep //*** 019 // IMPORTANT : ONLY USABLE BY NATIVE-SERVER // Tests the performance and if performance-indication is > 0 stays in this function via REPEAT and SLEEP // this function tests every 5 seconds if performance-indication is 0, // if it is or it is waiting for 1 minute, than it returns returns back to the calling program IF lrecObject.RECORDLEVELLOCKING THEN EXIT; lint := 0; WHILE PerformanceIndication() > 0 DO BEGIN SLEEP(5000); lint := lint + 1; IF lint >= 12 THEN EXIT; END;
Regards,Alain Krikilion
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!
0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions