Overview:
When trying to count the number of Note or Attachment records using the REST API (e.g. Salesforce Inspector), a non-admin user receives an OPERATION_TOO_LARGE error message. Why does this occur?
Root Cause:
Any user without the View All Data permission can only query for a particular number of records.
Answer:
The lack of View All Data permission requires a security calculation to be done for each record row and therefore this type of query is limited.
Record limits per object type:
- Notes: 20,000 distinct record ID's
- Attachments: 100,000 distinct records ID's
Related Documentation:
Salesforce Knowledge Article: Error: 'Operation too large'