How to produce Deadlock on non-indexed table

  • Hi Experts,

    I have been given a task to do a test.

    To put a load in the SQL server (large or purposely deadlocking query on non-indexed tables) to simulate a delay and to create potential time outs on SQL queries.

    Please let me know how to do it. And also please let me know how to find the non- indexed table and what query to use on it to produce deadlock.

    As i am newbie to SQL, please teach me how to do it.

    Thanks in advance

  • sqldba (6/13/2008)


    Hi Experts,

    I have been given a task to do a test.

    To put a load in the SQL server (large or purposely deadlocking query on non-indexed tables) to simulate a delay and to create potential time outs on SQL queries.

    Please let me know how to do it. And also please let me know how to find the non- indexed table and what query to use on it to produce deadlock.

    As i am newbie to SQL, please teach me how to do it.

    Thanks in advance

    To create the deadlock on nonindexed tables:

    create table t1 (a int)

    create table t2 (a int)

    -- in one query window:

    begin transaction

    insert into t2 values (1)

    delete from t1

    -- in another query window

    begin transaction

    insert into t1 values (2)

    delete from t2

    -- in the two query windows, execute the begin transactions, and then the insert statements, then after woth inserts were executed, execute in both the delete statements, you get a nice dedlock.

    Concerning finding unindexed tables, have a look at the sysindexes system table on 2000 (or sys.indexes on 2005 and 2008). Indexes with id (index_id) 0 mean the table is a heap table, 1 means the table has a clustered index, above one means the index is a non-clustered index (or xml, or spatial)

    Regards,

    Andras


    Andras Belokosztolszki, MCPD, PhD
    GoldenGate Software

  • Thanks for your reply.

    I wil try testing using this.

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

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