Cleaning msdyn_documentsection table

Keeping Dataverse at a low capacity usage can be challenging, but it's crucial to avoid extra costs and headaches. Today I'm going to talk about a table that was consuming over 40k GB of our database: msdyn_documentsectionBase (a.k.a. Document Section).

There's not much documentation about these tables, just a reference to them as system tables, but since they have a direct relationship with the Project table, we were concerned about deleting these records directly.

After contacting Microsoft, that's what they said:

The msdyn_documentsectionBase table is used to store snaphots of the mpp file backing the work breakdown structure seen in the Task tab of the project form.

It is taking so much space because in order to faciliate recovery, we generally store backups of the project file for up to 30 days in this table. Whenever a user navigates to the tasks tab of a project, we automatically purge all snaphots older than 30 days.

If a projects schedule has seen a lot of edits in a short period of time, and then is never edited again, it is possible for backups related to that project to never be cleaned up.

That last part explains why it was taking up so much space and not being purged after 30 days.

Luckily, Microsft recently released a new API that allows the manual cleaning of this table. It's called msdyn_DeleteRecoveryDataForPCS. It can be called in Power Automate using Perform a bound action:

Unrelate Row action calling the API
Perform a bound action calling the API

As of the publication of this post, there's no official documentation released for this API, but here's some clarifications from Microsoft:

We have confirmation from the product group team that DataWipeDate acts as on or before filter to wipe the data before that date.

(…) the product group team has confirmed that the API is designed to ensure that at least one record is retained to prevent any disruptions to the project. For instance, if you provide today's date and request to wipe everything, the API will make sure to keep at least one record intact to avoid breaking the project.

I hope that helps someone save some space in their database.

Don't stop learning!

Cassio Milanelo

Skilled and self-motivated Dynamics 365 CE developer and Power Platform jack of all trades. Acknowledged for high productivity and enthusiasm. Slightly workaholic and coffee lover ☕

This Post Has One Comment

  1. Marcel Lathouwers

    Hi Cassio, thanks for sharing.

    We had a chat with Microsoft on this topic as well. We have a customer base in accountancy and they create a lot of projects. As your post also mentions, there will always at least 1 record per project in this table. So, for our customers this table will still be quite large. But at one customer we managed to clean out 30 Gb 😏

Leave a Reply