Copied to clipboard

Flag this post as spam?

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


  • dominik 711 posts 733 karma points
    Nov 07, 2011 @ 14:03
    dominik
    0

    Database size problem

    Hello,

    Our Umbraco database is getting bigger and bigger. It looks like some tables are really big.

    - dbo.cmsPropertyData
    - dbo.cmsPreviewXml
    - dbo.umbracoLog

    Can this be stopped. I think log and preview can be deleted after a specific time or?

    Thanks for help

  • Hendy Racher 863 posts 3849 karma points MVP 2x admin c-trib
    Nov 07, 2011 @ 14:16
    Hendy Racher
    1

    Hi,

    yes the log data in umbracoLog can be deleted, and it's also possible to remove previous version values from the cmsPropertyData table.

    http://blog.thoehler.com/2009/02/27/cleaning-all-unnecessary-versions-via-sql.aspx

    -- Create a temporary table for all documents which are published and not in the recycle bin
    CREATE TABLE #Nodes (id int)
    -- Delete all rows if the table exists before
    TRUNCATE TABLE #Nodes

    -- Insert all nodeIds from all documents which are published and not in the recycle bin
    INSERT INTO #Nodes
    SELECT N.id
    FROM umbracoNode N
    INNER JOIN cmsDocument D ON N.ID = D.NodeId
    WHERE nodeObjectType = 'C66BA18E-EAF3-4CFF-8A22-41B16D66A972'
    AND [path] NOT LIKE '%-20%'
    AND D.Published = 1

    -- Create a temporary table for all versionId's to delete
    CREATE TABLE #Versions (id UniqueIdentifier)
    -- Delete all rows if it exists before
    TRUNCATE TABLE #Versions

    -- Insert all versionId's from all nodeIds in the #Nodes table
    -- and where published is set to false and newest is set to false
    INSERT INTO #Versions
    SELECT versionId
    FROM cmsDocument
    WHERE nodeId IN (SELECT id FROM #Nodes)
    AND published = 0 AND newest = 0

    -- DELETE all versions from cmsPropertyData, cmsContentVersion, cmsDocument
    -- from the nodes which are published and which are not in the recycle bin
    -- and which are not published and which are not the newest
    DELETE FROM cmsPropertyData WHERE VersionId IN (SELECT id FROM #Versions)
    DELETE FROM cmsContentVersion WHERE VersionId IN (SELECT id FROM #Versions)
    DELETE FROM cmsDocument WHERE VersionId IN (SELECT id FROM #Versions)

    DROP TABLE #Nodes
    DROP TABLE #Versions

    There's also a couple of useful packages:

    UnVersion: automatically remove previous versions

    FALM Housekeeping: can specify which previous versions to remove

    HTH,

    Hendy

  • dominik 711 posts 733 karma points
    Nov 07, 2011 @ 14:20
    dominik
    0

    Is there any reason why this is not deleted automatically?

    Thanks for your links

  • Hendy Racher 863 posts 3849 karma points MVP 2x admin c-trib
    Nov 07, 2011 @ 14:23
    Hendy Racher
    0

    To keep a version history so that content can be rolled back ?

  • dominik 711 posts 733 karma points
    Nov 07, 2011 @ 14:26
    dominik
    0

    ok but where can i config how long files are stored?

    We have just setup a umbraco test instance and database is abouer 445 MB.

    So it would be great if rollback is only possible within 10 days - after this time old files are removed

    Thanks

  • David Verberckmoes 46 posts 77 karma points
    Nov 07, 2011 @ 15:04
    David Verberckmoes
    0

    Hi,

    You might take a look at this tool: http://our.umbraco.org/projects/website-utilities/unversion from Matt.

    Don't touch the PropertyData table!

    I suppose you can remove old versions (older than 1 day) from the preview table.

    Rgds,

    David

  • dominik 711 posts 733 karma points
    Nov 07, 2011 @ 15:06
    dominik
    0

    Thanks

    will this delete log and property data and preview?

     

  • Jahan 20 posts 52 karma points
    Sep 13, 2017 @ 08:59
    Jahan
    0

    I have used F.A.L.M. Housekeeping in my website but there was not useful! My total MS SQL databases quota is 200 MB but my database size have been 326 MB! then I get an error

    "Warning: Subscription was suspended. All your sites are not available."

    in my Plesk panel. I don't want to upgrade my host!

    But is there any solution to reduce my db size under 200 mb? I have only 42 products in my website then I expect it a little space occupy.

  • Alex Skrypnyk 6150 posts 24110 karma points MVP 8x admin c-trib
    Sep 13, 2017 @ 10:27
    Alex Skrypnyk
    1

    Hi Jahan

    Try this sql query:

    -- Umbraco Clear Old Document Versions To Decrease Database Size And Improve Performance
    -- http://borism.net/2008/12/16/fixing-a-large-cmspropertydata-table-in-umbraco/
    DECLARE @createdDate Datetime = DATEADD(m, -1, getdate())
    
    -- dump logs
    -- TRUNCATE TABLE umbracolog -- faster if log table is very big and you don't need anything
    DELETE FROM umbracolog WHERE Datestamp < @createdDate
    
    -- clean up old versions
    DELETE FROM cmsPropertyData WHERE
        versionId NOT IN (SELECT versionId FROM cmsDocument WHERE updateDate > @createdDate OR published = 1 OR newest = 1) AND
        contentNodeId IN (SELECT DISTINCT nodeID FROM cmsDocument)
    DELETE FROM cmsPreviewXml WHERE
        versionId NOT IN (SELECT versionId FROM cmsDocument WHERE updateDate > @createdDate OR published = 1 OR newest = 1) AND
        nodeId IN (SELECT DISTINCT nodeID FROM cmsDocument)
    DELETE FROM cmsContentVersion WHERE
        versionId NOT IN (SELECT versionId FROM cmsDocument WHERE updateDate > @createdDate OR published = 1 OR newest = 1) AND
        ContentId  IN (SELECT DISTINCT nodeID FROM cmsDocument)
    DELETE FROM cmsDocument WHERE
        versionId NOT IN (SELECT versionId FROM cmsDocument WHERE updateDate > @createdDate OR published = 1 OR newest = 1) AND
        nodeId IN (SELECT DISTINCT nodeID FROM cmsDocument)
    
    --http://blog.dampee.be/post/2015/11/28/Remove-Old-versions-of-Umbraco-Previews.aspx
    delete
    --select *
    from cmsPreviewXml
    where versionId in (
        select cmsPreviewXml.versionId
        from cmsPreviewXml join cmsDocument on cmsPreviewXml.versionId=cmsDocument.versionId
    where cmsDocument.newest <> 1)
    
  • Jahan 20 posts 52 karma points
    Sep 13, 2017 @ 15:31
    Jahan
    0

    Hi Alex, Unfortunately, that was not useful!

    As you can see in the picture, "Jahan-Handicraftlog" has too large size. Is "Jahan-Handicraftlog" important? if not, how can I clean it?

    After executing the query for reducing the size of db

  • Marcio Goularte 388 posts 1360 karma points
    Sep 13, 2017 @ 17:41
  • Paul Stephenson 19 posts 129 karma points
    Sep 14, 2017 @ 07:32
    Paul Stephenson
    0

    Hi Jahan,

    Jahan-Handicraft_log is the SQL Server transaction log for your database, which always exists together with the main data file, Jahan-Handicraft. The filename column in that query tells you that the files really live on disk in C:\Data\....

    The top answer to the Stack Overflow question How do you clear the SQL Server transaction log? has some good pointers.

    The right thing to do depends on your backup strategy, particularly whether you are OK restoring from the last full backup or need point-in-time recovery.

Please Sign in or register to post replies

Write your reply to:

Draft