You are here:
ApexGuru Antipattern: Schema.getGlobalDescribe() Not Efficient
Using Schema.getGlobalDescribe() to retrieve metadata for a single known SObject isn’t efficient. This method causes unnecessary overhead, decreases performance, and increases the latency of the associated entry point.
Scope
Detection and recommendation
Detection Example
apex
Schema.DescribeSObjectResult dsr = Schema.getGlobalDescribe().get('Case').getDescribe();Recommendation
Use the getSObjectType() method to retrieve the
metadata.
Schema.DescribeSObjectResult dsr = Case.sObjectType.getDescribe();