-- 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)
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.
-- 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-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 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.
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
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
There's also a couple of useful packages:
UnVersion: automatically remove previous versions
FALM Housekeeping: can specify which previous versions to remove
HTH,
Hendy
Is there any reason why this is not deleted automatically?
Thanks for your links
To keep a version history so that content can be rolled back ?
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
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
Thanks
will this delete log and property data and preview?
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
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.
Hi Jahan
Try this sql query:
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 removing the old versions, you need to shrink the database.
https://docs.microsoft.com/en-us/sql/t-sql/database-console-commands/dbcc-shrinkdatabase-transact-sql
https://technet.microsoft.com/en-us/library/ms189080(v=sql.105).aspx
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
. Thefilename
column in that query tells you that the files really live on disk inC:\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.
is working on a reply...