7

Question

Does the distance between two Salesforce IDs indicate how many records have been created by other orgs?

Approach

Assuming I create a scheduled job that creates an Account periodically. The Account ID can be converted to a decimal (removing the first 6 character and the last 3 and then convert from base62 to decimal). Then I am able to subtract the "decimal id" of my previous record and know the number of accounts that have been created by all tenants of my instance.

Wondering

Is this approach working to determine how active other tenants are on the platform?

2
  • 2
    To those who have voted to close the question, I have to ask you to comment on the reason. It is a perfectly good question and it teaches the community about how the Salesforce Platform, I mean Lightning Platform, works. Just because the answer to the question is "No" doesn't mean the question is a bad one or should be closed. Commented Apr 6, 2018 at 16:54
  • 2
    Also: The question is not off-topic. The inner workings of the Platform are central to understanding the more complex ways it works. Commented Apr 6, 2018 at 16:55

3 Answers 3

10

No. IDs are not always sequential, you don't know the volume of records created by other tenants, IDs are globally unique, and records are deleted all the time. Having worked at Salesforce, I got this question a lot, and the answer is that you shouldn't read anything into the record IDs. Plus, with prefixes set for custom objects, you have no idea how many of those are even in existence.

3
  • Hi David, I monitored the Account IDs of several orgs. Within a single pod the ids are always sequential increasing. Given that this should allow me to measure how many accounts have been created by others in the same pod. Is that right? Commented Apr 11, 2018 at 9:27
  • As said by someone else here, running tests will also increment the recordIDs, so you don't know how many Account records are created in a given time period. Plus, you don't know how many are deleted by other orgs. Why do you even want to know how many are created by others in the same pod? Commented Apr 13, 2018 at 23:51
  • Also, your question asks if you can know how active other tenants are on the platform. What's your metric? Account creation? What about Case Creation? You'll never know if your metric is custom object creation because you have no idea what the prefixes are for those objects. Many customers use orgs to create few SObject records, but read records quite a bit. So without a specific metric you think can measure activity, I think you're out of luck. Sorry! Commented Apr 13, 2018 at 23:54
5

The Id values are allocated in batches within each pod (instance), so there's not even a guarantee that that you'll have strictly sequential numbers even in the same insert transaction. This also means that it's theoretically possible for a record created in one org to have a lower-sequential number than a record created earlier in another org. Also, unit tests consume ID values but they don't persist beyond the test. In other words, there's no way to even guess how many records were "really" created, since we don't know many of the internals, including how batches are allocated, how large they are, how quickly they tend to be exhausted, etc.

4

In addition to the other answers, you mention:

The Account ID can be converted to a decimal (removing the first 6 character and the last 3 and then convert from base62 to decimal).

I assume you are working from the 18 character id's since you are removing the trailing three characters.

Those first three characters include not only the Account keyprefix, but also the pod identifier. See What are Salesforce ID's composed of?.

I haven't experimented with it, but because record ID's are unique across all tenants (Sandboxes are an exception to this rule of Id's being unique) interesting things could happen due to pod migrations.

Here is an example I found of this phenomenon in a developer edition org that was migrated from NA5 to NA64.

enter image description here

Note how the ID's sorted by CreatedDate are ordered:

  1. 0017000001Y1ZW1AAN
  2. 0010g00001XZwCGAA1 After the pod migration we've gone back to 01X...
  3. 0010g00001YgmdVAAR NA64 reaches 1Y again

That said, you can get a very rough approximation of activity. As sfdcfox points out, IDs allocated in tests and those in rolled back transactions are going to skew the results for the actual number of records created.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .