My requirement as part of org analysis is to get list of all custom objects having more than 100000 records and created date of LAST CREATED record.
My tries are as follows:-
Go to Setup - Storage usage - list of all objects with record count is available here.(however it is a mix of standard and custom objects moreover there is no way to get a last created date.
BASED on
A. How can I know number of records of All Salesforce Object? B. Salesforce Objects & record Counts
I wrote following code(but it is giving fatal error possibly because of too many objects and 'change' condition processing time) Also without change condition it continues to give me errors:-
for ( Schema.SObjectType o : Schema.getGlobalDescribe().values() )
{
Schema.DescribeSObjectResult objResult = o.getDescribe();
system.debug( 'Sobject API Name: ' + objResult.getName() );
String obj = objResult.getName();
if('EmailStatus' == obj || obj == 'Name' || obj == 'Vote' || obj == 'AggregateResult'
|| obj == 'CampaignChangeEvent' || obj == 'AccountChangeEvent' || obj == 'ContractChangeEvent'
|| obj == 'LeadChangeEvent' || obj == 'OpportunityChangeEvent' || obj ==
'OpportunityContactRoleChangeEvent'
|| obj == 'Product2ChangeEvent' || obj == 'AssetChangeEvent' || obj == 'CaseChangeEvent' ||
obj.contains('Change') )
continue;
String q = 'SELECT Count() FROM ' + obj;
Integer count = Database.countQuery(q);
System.Debug(objResult.getName() + '-->' + count);
}