I use the open source project SubText to power my blog and have been for years. For me, it works great. However there's one little dirty secret about it: it logs every single inbound URL request for trackbacks & pingbacks... just like most blog software does. All of this gets logged to two tables: subtextReferrals & subtextURLs. After a while, these guys can fill up to be quite big... specifically the URLs table.
Unfortunately there's a TON of crap and spam in this data. Not only do spammers exploit it, but the hits coming from search engines causes it to bloat quite a bit as well. Because I host my site at a shared provider, I'm allocated only a certain amount of SQL storage and if I go over, I have to pay more.
So last week I got my most recent overage bill and decided to deal with it. My database was about 700MB and all it contained was TEXT data! Investigating a bit showed me that my subtextURLs table had over 1.4M records and that, combined with the indexes on that table took up over 500MB! Add in the subtextReferrals table and I had a lot of waste. Unfortunately purging it like others have wasn't working because my transaction log was filling up and kept failing the delete actions.
If you're like me and could care less about your pingbacks & trackbacks, what you can do is the heavy handed approach: truncate all this data! Here's the script I use to purge my subtextReferrals & subtextURLs tables. After running this I'm down to just around 25MB... giving me PLENTY of space before I get another overage bill from my host!
IF EXISTS (SELECT * FROM sys.foreignkeys WHERE objectid = OBJECTID(N'[dbo].[FKsubtextReferralssubtextURLs]') AND parentobjectid = OBJECTID(N'[dbo].[subtextReferrals]'))ALTER TABLE [dbo].[subtextReferrals] DROP CONSTRAINT [FKsubtextReferralssubtextURLs]GO
TRUNCATE TABLE [dbo].[subtextReferrals]TRUNCATE TABLE [dbo].[subtextURLs]
ALTER TABLE [dbo].[subtextReferrals] WITH CHECK ADD CONSTRAINT [FKsubtextReferralssubtextURLs] FOREIGN KEY([UrlID])REFERENCES [dbo].[subtextURLs] ([UrlID])GO
ALTER TABLE [dbo].[subtextReferrals] CHECK CONSTRAINT [FKsubtextReferralssubtextURLs]GO
DBCC DBREINDEX ([subtextReferrals])DBCC DBREINDEX ([subtext_URLs])DBCC SHRINKDATABASE(0)