web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Reducing DB Size

(0) ShareShare
ReportReport
Posted on by 7

Hello,

Seeking to reduce db size in preparation for migration from on-prem to online environment.

Currently dbo.Attachment and dbo.ActivityPointerBase are largest tables with 33GB and 24GB respectively.

I've used bulk deletion to deleted all emails with attachments over 1MB. But not change to Attachment table size. Why is this?

Any guidance for reduces other top 10 table sizes?

Thank you!

52384747.Capture.PNG

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Siva L Profile Picture
    40 on at

    That is strange. Usually, the table size reduces, but the database size remains same. 

    Could it be possible that most of your cases have multiple attachments that collectively have size greater than 5 MB, but are individually lesser? 

    if you have the counts of records before and after deletion, you will be able to validate better. 

  • Community Member Profile Picture
    on at

    In order to reduce the db size, in particular concerning attachments, you can consider to store the attachments in sharepoint.

    1. Develop a webservice that can write,delete and retrieve data in sharepoint.

    2. Develop a plugin that triggers on creation, delete and retrieves of attachments

    Create:

    When the attachment is created in crm, a plugin calls the sharepoint webservice, stores the attachment in sharepoint and (IMPORTANT) update the attachment.body to NULL, automaticly the attachment.filesize is updated to 0.

    Delete:

    When a attachment is deleted in crm, delete the file in sharepoint by using the SP webservice delete function.

    Retrieve:

    When the emailform is loaded, in background a retrieve of the attachments is done in the crm db, for every retrieve the plugin does a retrieve in sharepoint and receives the filesize. In the plugin context you update this filesize from sharepoint, otherwise the attachment has a filesize of 0 in crm.

    When you click on the attachment, you also do a retrieve in sharepoint to return the body, and update in the plugin the body in the context. This way, when you click in crm on a attachment, that is stored in SP, you get this attachment in SP, and can open it in crm. Nobody will see that the attachment in the background is stored en received in sharepoint.

    This way you can reduce gb's of data in the crm database.

    This way, when someone or the emailrouter creates a email with for example 16 attachments, all 16 attachments will be stored in sharepoint , and in the crm attachment table the body will be NULL , and filesize 0 .

    In order to clear up the existing historicly data in attachments, write a service or console application and read from the attachment table and upload the data to sharepoint by using the sharepoint webservice.

    There are several commercial packages that do these actions, but it's also written by yourself in 2 days.

    This way i cleared up millions of attachments in a customers database.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the April Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
ScottDurow Profile Picture

ScottDurow 2

#2
GJones Profile Picture

GJones 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans