October 12, 2003 at 4:02 am
I have a session table:
CREATE TABLE [dbo].[session] (
[session_id][char](32) NOT NULL ,
[data][text] NOT NULL ,
[last_update][smalldatetime] NOT NULL
) ON [PRIMARY]
ALTER TABLE [dbo].[session] WITH NOCHECK ADD
CONSTRAINT [PK_session] PRIMARY KEY NONCLUSTERED ([session_id]) ON [PRIMARY]
GO
CREATE INDEX [LastUpdate] ON [dbo].[session]([last_update]) ON [PRIMARY]
GO
Trying to delete old sessions with:
DELETE session
WHERE last_update < (GETDATE()-1)
It takes MINUTS to complete on 10K rows.
Avron
October 15, 2003 at 8:00 am
This was removed by the editor as SPAM
October 15, 2003 at 2:37 pm
I tried your example - and made the Primary Key CLUSTERED instead of non clustered. It deleted the 10K sample records I had added in about 1 second.
As a non clustered key it had run for over 30 seconds before I cancelled it. Looks like the non clustered key was your problem.
October 19, 2003 at 2:10 am
Thanks Magnaley2000.
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply