Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Very large number of records in SiteTree_versions


Reply


3 Posts   1501 Views

Avatar
andy_steel

Community Member, 31 Posts

24 April 2009 at 9:24pm

Hi,

I've noticed that one of our SS sites has 86,000 records in the SiteTree_versions table. There are only 166 pages in the SiteTree folder.

This is causing problems when releasing new updates to the site. I added a new page type, so this changed the ENUM on the SiteTree_versions table, causing the query to run for 5 - 10 minutes.

I would rather not remove all records from this table. Keeping the last revision or 2 would make sense. What is the best way to clear out the majority of these records?

Thanks,
Andy

Avatar
rbquirke

Community Member, 70 Posts

25 April 2009 at 12:02am

changing the table structure (which is what you are doing adding a new page type) is going to take a while to run, but this is only an issue when adding new code to the site. It should not affect day to day operations.

If you do want to remove some of the rows from the Sitetree_versions table, you could run an sql command like:
"DELETE FROM `SiteTree_versions` WHERE `Created` < '2009-03-01 00:00:00'"

This would delete all rows created before March 1st. You could write something trickier to only leave the two most recent versions, but that would take a bit of effort....

Deleting rows should not affect the revision function (other than removing old data).

Avatar
andy_steel

Community Member, 31 Posts

25 April 2009 at 12:48am

Thanks rbquirke.

I think I'll remove the old revisions by date. The other method will take too long to implement.

Having too many records in the versions table is quite dangerous since running /dev/build on a live server can kill the performance on a server.
Perhaps it is worth adding a fix (or at least warning) to the /dev/build scripts to solve this issue?