Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Johan Dahlström 33 posts 146 karma points
    Sep 16, 2022 @ 11:37
    Johan Dahlström
    0

    The umbracoPropertyData table keeps growing

    Hi, I've noticed that dbo.umbracoPropertyData increases in size pretty quickly. We have a fairly new project and it's already getting towards 4GB in size.

    Will Umbraco just keep adding rows or will old rows be removed eventually? If not, how can this be maintained?

  • Roy Berris 89 posts 576 karma points c-trib
    Sep 16, 2022 @ 13:14
    Roy Berris
    0

    I believe this will be fixed with the content version cleanup feature introduced in 9.1.0.

    https://our.umbraco.com/documentation/Fundamentals/Data/Content-Version-Cleanup/

    In 8 versions there was this package: https://our.umbraco.com/packages/website-utilities/unversion/ but it shows it is retired. I do think it should still work for 8 installations tho.

  • Bo Jacobsen 597 posts 2395 karma points
    Sep 16, 2022 @ 14:40
    Bo Jacobsen
    100

    Hi Johan.

    The history cleanup is introduced in 8.18.0.

    But if you can't upgrade, then unversion as Roy is suggesting is working like a charm.

    If you just wanna do a simple cleanup, where you remove all versions except the last 4. Then you can do this.

    public class UnVersionComponent : IComponent
    {
        private readonly ILogger _logger;
        private readonly IContentService _contentService;
    
        public UnVersionComponent(ILogger logger, IContentService contentService)
        {
            _logger = logger;
            _contentService = contentService;
        }
    
        public void Initialize()
        {
            ContentService.Published += ContentService_Published;
        }
    
        private void ContentService_Published(global::Umbraco.Core.Services.IContentService sender, global::Umbraco.Core.Events.ContentPublishedEventArgs e)
        {
            foreach (var content in e.PublishedEntities)
            {
                var allVersionsToDelete = _contentService.GetVersionsSlim(content.Id, 4, int.MaxValue).ToList();
                foreach (var version in allVersionsToDelete)
                {
                    _logger.Debug<UnVersionComponent>("Deleting version id {VersionId} of content id {ContentId}", version.Id, content.Id);
                    _contentService.DeleteVersion(content.Id, version.Id, false);
                }
            }
        }
    
        public void Terminate() { }
    }
    
  • Johan Dahlström 33 posts 146 karma points
    Sep 19, 2022 @ 08:46
    Johan Dahlström
    0

    Thanks Bo, I think this is sufficient for my use case

Please Sign in or register to post replies

Write your reply to:

Draft