The performance of operations on a Salesforce org may vary based on a wide variety of factors, including
- The overall load in your org, for some operations such as asynchronous code.
- The overall load on the instance where your org lives.
- The data volume in your org, including both overall quantity and data shape issues like skew.
Some of these things are wholly or partially outside of your control, and they're not easy to visualize or monitor without close investigation.
There are certainly things you can do within your code to ensure that it is performant. Performing selective queries based on indexed fields is a big one, which it sounds like you're already doing. If your code does no more than perform an optimized query and return a result, there's likely little more that you can do to optimize its performance.
You could consider, based on your description of this code, relying on the native REST API instead to get a record by External Id.