We have a Process Builder which currently gets a hardcoded Salesforce Id out of an abused label and assigns it to the record. Of course, this means the solution causes tests to fail outside production.
I would like to refactor it. Instead, I'd like to store the name of the record in a custom setting, use SOQL to look up the Id, and then assign the Id to the record. But, obviously, because of governor limits, I don't want the SOQL to execute again for every record.
If I store the value in some static variable and check whether the value is null before executing the query, or using the value if it is not, can I rely on the SOQL query only executing once regardless how many records are being processed?