Loading
Salesforce から送信されるメールは、承認済ドメインからのみとなります続きを読む

ContentBody Usage: Avoid SOQL for Counting

公開日: Sep 29, 2025
説明

Issue

Administrators may observe significant discrepancies between the number of ContentDocument records returned by SOQL queries and the ContentBody record count displayed on the Storage Usage page, leading to confusion about actual file storage consumption and difficulty in managing storage quotas.

Symptoms

  1. SOQL queries on ContentDocument or ContentVersion return significantly fewer records than expected.

  2. Storage Usage page displays much higher ContentBody counts

  3. Sum of individual user storage in "Top Users by File Storage Usage" does not match total file storage usage

  4. Administrators cannot locate or access all files that contribute to storage consumption through standard SOQL queries

Cause

This behavior is working as designed due to fundamental differences between SOQL query capabilities and storage calculation algorithms used by the Storage Usage page. The Storage Usage page uses algorithms that account for all ContentBody usage across multiple platform features and not just ContentVersion records. ContentBody storage includes data from various sources beyond traditional file uploads:

  • ContentVersion records

  • ContentReference records (images and files in Rich Text fields)

  • ContentNote records (which internally use Rich Text fields)

  • Feed posts with embedded images and rich content

  • Other platform features that utilize blob storage

 

SOQL Query Limitations:

 

  • SOQL queries on ContentDocument and ContentVersion only return files that are directly accessible to the querying user

  • Simple COUNT() queries cannot replicate the complex storage calculations performed by the platform

  • SOQL queries do not account for all sources of ContentBody usage across the platform

解決策

The discrepancy between SOQL results and Storage Usage calculations is expected behavior. The Storage Usage page provides the authoritative view of actual storage consumption across all platform features, while SOQL queries show only a subset of accessible files.

Recommended Approaches for Storage Management

  1. Use Storage Usage Page as Primary Reference

 

  • Rely on the Storage Usage page for accurate storage consumption metrics

  • Focus on the "Top Users by File Storage Usage" section to identify high-usage users

  • Use the detailed user storage breakdown to prioritize cleanup efforts

 

  1. Enable Proper File Access Permissions

 

  • Ensure administrators have the "Query All Files" permission enabled

  • Remove "Query Non Vetoed Files" permission from human user profiles (this permission should only be used for system integrations)

  • Verify that administrators can access files across all libraries and sharing boundaries

 

  1. Comprehensive File Cleanup Strategy

 

  • Target high-usage users identified in the Storage Usage page

  • Clean up Rich Text field content that may contain embedded images

  • Review and clean up Chatter feed posts with attachments

  • Use "Login As" functionality to access individual user files when necessary

  • Focus on ContentNote cleanup if extensive note-taking features are used

 

  1. Alternative Query Approaches

 

  • Query by CreatedById or OwnerId to find files created/owned by specific users

  • Access individual user storage details through the Storage Usage page links

ナレッジ記事番号

005224377

 
読み込み中
Salesforce Help | Article