I have written a small Apex class to fetch list of all available (Standard+Custom) Objects in Org and their fields.
But when trying to retrieve total record of individual Object, this is showing too many SOQL issue. I understand this is happening due to the Query inside For{}. Is there any other way to fetch All Objects' total records.
Map<String, Schema.SObjectType> GlobalMap = Schema.getGlobalDescribe();
for (Schema.SObjectType Obj : GlobalMap.values()) {
Schema.DescribeSObjectResult ObjDesc = Obj.getDescribe();
system.debug(' Object Name : ' + ObjDesc.getName());
system.debug(' Object Fields : ' + ObjDesc.fields.getMap().keySet().size());
AggregateResult arRecs = Database.query('Select count(id) nRecs from '+ObjDesc.getName());
system.debug(' Total Records : ' + Integer.valueOf(string.valueOf(arRecs.get('nRecs'))));
}
}
ApexClass
is included ingetGlobalDescribe
so you would include the number of Apex Classes in your org in your count.