0

I know that the best practice for Master Detail Relationship is 10,000 child records per parent. But there is a recomendation for lookup relationship?

4

Both master-detail and lookup relationships are indexes and can be used when you query for records.

The concern with having so many records related to a single parent record is that you may experience index skew.

Without going too deep into details, database indexes are useful to narrow down the set of results that a query has to process and return (which becomes important when you're a company like Salesforce, which services tens of thousands of customers, internationally, 24/7). Indexes work best when they are uniformly distributed (there are roughly an equal number of records for each index value).

If you exceed 10k records related to a single parent, then your index is likely to be "skewed" (the distribution becomes "peaky"), meaning it's less useful in making your query selective.

In that sense, the recommendation for master-detail relationships also applies to lookup relationships.

There's nothing inherently special about that 10k threshold (at least, not that's widely known to the general public), and it's likely that you'll start experiencing issues before you get to that point.

2
  • Thank you Derek, perfect answer.
    – user87331
    Nov 4 '20 at 21:29
  • +1. Lookup skew is also a very common contributor to row locking issues.
    – David Reed
    Nov 4 '20 at 22:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.