Skip to main content

Notifications

Microsoft Dynamics CRM (Archived)

Reducing DB Size

Posted on by 5

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

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Reducing DB Size

    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.

  • Suggested answer
    Siva L Profile Picture
    Siva L 40 on at
    RE: Reducing DB Size

    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. 

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Community AMA December 12th

Join us as we continue to demystify the Dynamics 365 Contact Center

New! Quick response templatesâš¡

Save time with the new custom templates!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,151 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 229,993 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans