I have something ridiculous like over 4 million rows in the table now and the interface is so painfully slow its unusable. I need to remove all automatically added entries. Is the following query safe to use for this?
DELETE FROM [dbo].[icUrlTracker]
WHERE RedirectNodeId IS NULL AND RedirectUrl IS NULL
Haha thanks Stefan, I think I might stick with my query which as far as I can tell is all useless data anyway as it's not redirecting anywhere. I just need to make sure it deletes in batches due to the volume of data to remove!
Final query seemed to work nice and quick locally by copying the records I want to keep out to a temporary table, truncating the existing table and putting the records back:
CREATE TABLE #TempUrlTracker
(
[Id] INT IDENTITY (1, 1) NOT NULL,
[OldUrl] NVARCHAR (1000) NULL,
[OldUrlQueryString] NVARCHAR (1000) NULL,
[OldRegex] NVARCHAR (1000) NULL,
[RedirectRootNodeId] INT NULL,
[RedirectNodeId] INT NULL,
[RedirectUrl] NVARCHAR (1000) NULL,
[RedirectHttpCode] INT DEFAULT ((301)) NOT NULL,
[RedirectPassThroughQueryString] BIT DEFAULT ((1)) NOT NULL,
[Notes] NVARCHAR (1000) NULL,
[Is404] BIT DEFAULT ((0)) NOT NULL,
[Referrer] NVARCHAR (1000) NULL,
[Inserted] DATETIME DEFAULT (getdate()) NOT NULL,
[ForceRedirect] BIT CONSTRAINT [DF_icUrlTracker_ForceRedirect] DEFAULT (0) NOT NULL
);
SET IDENTITY_INSERT #TempUrlTracker ON;
INSERT INTO #TempUrlTracker ([Id], [OldUrl], [OldUrlQueryString], [OldRegex], [RedirectRootNodeId], [RedirectNodeId], [RedirectUrl], [RedirectHttpCode], [RedirectPassThroughQueryString], [Notes], [Is404], [Referrer], [Inserted], [ForceRedirect])
SELECT [Id],
[OldUrl],
[OldUrlQueryString],
[OldRegex],
[RedirectRootNodeId],
[RedirectNodeId],
[RedirectUrl],
[RedirectHttpCode],
[RedirectPassThroughQueryString],
[Notes],
[Is404],
[Referrer],
[Inserted],
[ForceRedirect]
FROM [dbo].[icUrlTracker]
WHERE redirectNodeId IS NOT NULL
OR RedirectUrl IS NOT NULL;
SET IDENTITY_INSERT #TempUrlTracker OFF;
TRUNCATE TABLE [dbo].[icUrlTracker];
SET IDENTITY_INSERT [dbo].[icUrlTracker] ON;
INSERT INTO [icUrlTracker] ([Id], [OldUrl], [OldUrlQueryString], [OldRegex], [RedirectRootNodeId], [RedirectNodeId], [RedirectUrl], [RedirectHttpCode], [RedirectPassThroughQueryString], [Notes], [Is404], [Referrer], [Inserted], [ForceRedirect])
SELECT [Id],
[OldUrl],
[OldUrlQueryString],
[OldRegex],
[RedirectRootNodeId],
[RedirectNodeId],
[RedirectUrl],
[RedirectHttpCode],
[RedirectPassThroughQueryString],
[Notes],
[Is404],
[Referrer],
[Inserted],
[ForceRedirect]
FROM #TempUrlTracker;
SET IDENTITY_INSERT [dbo].[icUrlTracker] OFF;
IF (OBJECT_ID('tempdb..#TempUrlTracker') IS NOT NULL)
BEGIN
DROP TABLE #TempUrlTracker;
END
Remove Automatic Entries
I have something ridiculous like over 4 million rows in the table now and the interface is so painfully slow its unusable. I need to remove all automatically added entries. Is the following query safe to use for this?
Is there anything else I need to consider?
Thanks, Simon
Hi Simon,
The UrlTracker source describes an automatic entry as follows:
Yes, it's ugly :-)
Haha thanks Stefan, I think I might stick with my query which as far as I can tell is all useless data anyway as it's not redirecting anywhere. I just need to make sure it deletes in batches due to the volume of data to remove!
Cheers, Simon
Final query seemed to work nice and quick locally by copying the records I want to keep out to a temporary table, truncating the existing table and putting the records back:
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.