In dynamic APEX, as mentioned by SF that describe calls are heavy. So when we do the following

  1. Schema.getGlobaldescribes() - it picks org's all objects.
  2. Schema.getGlobaldescribes().get(SObjectAPIName) - does it pick only specific SObject mentioned in get() or start from left to right of the dot i.e. 1st will pick all the org's sObjects and then specific object.

Reason- I have a specific number of objects say 2, child and parent. Want to show the label of the fields on the basis of the user's input in a box having comma-separated API name of the fields. There is a need to show the label of the fields the user entered earlier. e.g. Field : Account.Name,Title,FirstName, LastName (all contact fields)

Label of the input boxes should be
Account Name = (value by user)
Title = (value by user)

The answer will allow me to decide to do describe calls ones and play with them (but will be heaviest) or play with dot notation to reduce the burden on processing time.

  • 2
    Because the get call operates on the map already retrieved this necessarily has exactly the same poor performance as making the call to fetch the map then get the value from the map in a separate statement.
    – Phil W
    Commented Mar 6, 2022 at 8:13
  • @PhilW - yes I thought the same, wanted to make sure that SF has backward compatibility to improve performance i.e. right to left execution somehow. Also, I am analysing the details given in the first response link, this is awesome. Giving me a new perspective to think and play. Thanks a lot.
    – Rohit
    Commented Mar 6, 2022 at 8:39
  • Apex processes code always top to bottom, left to right. I cannot see how the language could do anything else, "optimizing" certain sequences, especially in a general manner. Glad the other Q&A was of interest.
    – Phil W
    Commented Mar 6, 2022 at 9:39


Browse other questions tagged .