Large Database Size

Topics: User Forum
Mar 30, 2012 at 8:13 AM

Our N2CMS database has grown in size to around 10GB since going live with a site in November. I believe most of the data is version history, is there a way of removing this information?

Mar 30, 2012 at 7:56 PM

I'm away from the N2 source code and I don't remember the name but aside from doing it through the UI (versions), you can add an attribute that specified the maximum number of version history to keep for a content item. A quick search should allow you to find it... Of course, I would think the older revisions will only really get deleted the next time you edit the content item...

Apr 5, 2012 at 2:04 AM

It's in the web.config. I found this in my docs:

Section: <n2><edit><versions>

Manages whether multiple versions of content items are preserved when they are edited. The older versions can be accessed in the N2 administrator panel through the "versions" button.

enabled

If true, multiple revisions of each content item are stored in the version history. If false, only the current version of each item is stored. Default true.

maximumPerItem

The maximum number of revisions of a content item to be stored in the database. Default 100.

Hope it helps :)

Apr 5, 2012 at 6:45 AM

I use this SQL to delete all old versions at time to time and haven't had any problems. Be aware it will remove everything that's expired. Use at own risk after backup of database.

USE [name-of-your-database]
DELETE FROM n2Detail where ItemID in (select ID from [N2CMS].[dbo].n2Item where Expires < GETDATE())
DELETE FROM n2Detail where LinkValue in (select ID from [N2CMS].[dbo].n2Item where Expires < GETDATE())
DELETE FROM n2DetailCollection WHERE ItemID in (select ID from [N2CMS].[dbo].n2Item where Expires < GETDATE())
DELETE FROM n2Item where Expires < GETDATE()

Apr 10, 2012 at 4:59 PM

Thanks, I've stuck in the web.config and use the SQL to clear down the database.