My Apex code in a Sandbox will execute a DML Insert that will create an Account. It would simplify my algorithm if I were certain that the new record's ID could not possibly match that of an Account in the Production org.
1 Answer
It is, in fact, 100% guaranteed that any record created in a Sandbox will never have an Id that could match anything in Production. Every ID has a two-digit "pod" identifier as part of the Id (see this answer and this other answer). Any record you create in a Sandbox will have as part of its Id the unique pod identifier.
So, for example, while an ID in production might be 0014000000abcde, a record created in a sandbox might be 001Q000000abcde, even if, all things being equal, they were created in a way that allowed the last 9 characters to be the same (as in this arbitrary example).
Note that for any record created in Production, if copied to a Sandbox via a Sandbox creation or refresh, the Id will be identical. For example, User Ids, Profile Ids, and other common metadata that is copied will have the same Id values. This is the only time an Id will be identical in both Production and a Sandbox.