How do I get the transforms of all the objects in my scene ?

I have a pretty huge scene with more than 5000 gameobjects. My quest is to get the transforms of all the objects through a C# script. How can I do so in an efficent manner? Any help is highly appreciated!
PS: I’m using Unity 2019.3

Can’t say anything about efficiency, but FindObjectsOfType is able to find all objects of a specific type in open scenes. This includes components.

Perhaps getting root gameObjects (UnityEngine.SceneManagement.SceneManager.GetActiveScene().GetRootGameObjects()) and recursively visiting all of its children (and getting their transforms) would be more efficient than FindObjectsOfType, since every gameObject has exactly one transform - but I can’t say without trying.
Also, depending on what your goal is, you might not need to store them in a collection (a list), but just iterate over them. Or perhaps, you might want to stop iterating after some goal has been reached (you already found all the transforms you actually needed for your purpose)