Why does it take so much time

  • 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

  • This was removed by the editor as SPAM

  • 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.

  • Thanks Magnaley2000.

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply