Remove old records from Umbraco cmsPreviewXml table

by Damiaan Peeters 28. November 2015 01:24

I just got a production database.  This database was massive.  One of the big tables was the cmsPreviewXml. 

To clean up the Umbraco cmsPreviewXml run the SQL script below.  This will delete all older previews, but keep the most recent.

select *
from cmsPreviewXml
where versionId in (
    select cmsPreviewXml.versionId
    from cmsPreviewXml join cmsDocument on cmsPreviewXml.versionId=cmsDocument.versionId
    where cmsDocument.newest <> 1)

The other scripts I used to clean the umbraco database are in this gist:

Certified Umbraco Master, Part of Umbraco Certified partner comm-it, .Net and Azure developer, seo lover. Magician in my spare time.

Month List