countPersistentInstancesLimit

countPersistentInstancesLimit(limit: Integer): Integer;

The countPersistentInstancesLimit method of the Class class returns the number of non-exclusive persistent instances of the receiver class up to the value specified by the limit parameter.

The countPersistentInstancesLimit method is significantly faster than the size method on an instances pseudo-collection, as shown in the following code fragments.

write Customer.instances.size;
write Customer.countPersistentInstancesLimit(500000);      // significantly faster

This countPersistentInstancesLimit method can be used instead of the countPersistentInstances method to limit the time used, but the result will not be correct if actual count is greater than the value of the limit parameter.

This method impacts other users of the database file where the instances of the receiver class are stored. The best time to run this method is therefore when there are few other active users.