getMostAccessedClasses
getMostAccessedClasses(clsNumArray: IntegerArray input; freqArray: Integer64Array input; maxWanted: Integer);
The getMostAccessedClasses method of the System class returns access counts for the classes that have been most frequently accessed since the database server node was initialized.
The access counts for classes are held on the database server node and are incremented every time an instance of that class or one of its subobjects is written to the database or fetched from the database. Only persistent object accesses are counted.
The access counts do not indicate how many times applications have used objects. If an object resides in the persistent object cache, it may not have to be fetched from the database when used. The access counts reflect database activity, rather than application activity.
The information is returned in a pair of arrays. The clsNumArray array contains a set of class numbers, and the freqArray array contains a matching set of access counts. Each entry in the freqArray array corresponds to the entry with the same index in the clsNumArray array.
The entries in the array are sorted in descending order of access count; that is, the class with the highest access count is the first array member, the class with the second highest access count is second, and so on.
The maxWanted parameter specifies the maximum number of entries to be placed in the arrays.
The calling process is responsible for creating and deleting the clsNumArray array and the freqArray array.
When the getMostAccessedClasses method is called, the arrays passed as parameters are cleared of all entries.
The access counts are cumulative values, which do not get reset during the lifetime of the database server node, are held as 64-bit unsigned integer values and added to the freqArray array object as
When dealing with classes, the class that has a particular number can be found using the getClassByNumber method of the Schema class.
The following example shows the use of the getMostAccessedClasses method.
showMostAccessedClasses(); vars clsNumArray: IntegerArray; freqArray: Integer64Array; ix : Integer; cls : Class; begin create clsNumArray transient; create freqArray transient; system.getMostAccessedClasses(clsNumArray, freqArray, 1000); foreach ix in 1 to clsNumArray.size do if clsNumArray[ix] > 2047 then //only show user classes cls := currentSchema.getClassByNumber(clsNumArray[ix]); write "Schema " & cls.schema.name & " Class " & cls.name & " Accesses=" & freqArray[ix].String; endif; endforeach; epilog delete clsNumArray; delete freqArray; end;
The output from the getMostAccessedClasses method shown in the previous example is as follows.
Schema CompilerVersioningTests Class TestInfo Accesses=25 Schema CompilerSchema Class C1 Accesses=6 Schema CompilerSchema Class C2 Accesses=4 Schema CompilerSchema Class C2Dict Accesses=4 Schema Martini Class SportsTeam Accesses=4 Schema CompilerSchema Class C1Dict Accesses=2 Schema CompilerSchemaImport Class GCompilerSchemaImport Accesses=1 Schema CompilerSchema Class GCompilerSchema Accesses=1 Schema CompilerSchemaSub Class GCompilerSchemaSub Accesses=1 Schema Martini Class GMartini Accesses=1 Schema Martini Class Root Accesses=1 Schema CompilerVersioningTests Class GCompilerVersioningTests Accesses=1