DROP TABLE takes long time on production.

Alan5896 26 Reputation points
2022-08-23T20:21:05.75+00:00

Why on production takes to run long time drop table abcde after query below.
On test database drop table abcde after run below query less then 1 sec.
Why on production it takes long time?

CREATE TABLE abcde (  
ID int NOT NULL IDENTITY(1, 1) PRIMARY KEY  
, Type varchar(10) default 'Grid'  
, PageNo int default (0) , RowNo int default (0)  
, SRS_ID int default 0 , OracleID int default 0  
, EmpDiv varchar(100) default ''  
, First_Name varchar(1000) default ''  
, Last_Name varchar(1000) default ''  
, Preferred_Name varchar(1000) default ''  
, Employer varchar(1000) default ''  
, empid int default 0  
, address varchar(100) default ''  
, aa varchar(100) default ''  
, bb varchar(100) default ''  
, cc varchar(100) default ''  
)  
  
  
  
INSERT INTO abcde (EmpID, First_Name, Last_Name, aa, bb, cc)  
SELECT ID,firstname, lastname, address, state, phone  
FROM Employee  
WHERE status = 1  
  
  
  
SELECT tt.SRS_ID, tt.SRS_ID FROM abcde tt WHERE Type = 'Grid' GROUP BY tt.SRS_ID  
SELECT tt.OracleID, tt.OracleID FROM abcde tt WHERE Type = 'Grid' GROUP BY tt.OracleID  
SELECT tt.EmpDiv, tt.EmpDiv FROM abcde tt WHERE Type = 'Grid' GROUP BY tt.EmpDiv  
SELECT tt.First_Name, tt.First_Name FROM abcde tt WHERE Type = 'Grid' GROUP BY tt.First_Name  
SELECT tt.Last_Name, tt.Last_Name FROM abcde tt WHERE Type = 'Grid' GROUP BY tt.Last_Name  
SELECT tt.Preferred_Name, tt.Preferred_Name FROM abcde tt WHERE Type = 'Grid' GROUP BY tt.Preferred_Name  
SELECT tt.Employer, tt.Employer FROM abcde tt WHERE Type = 'Grid' GROUP BY tt.Employer  
SELECT tt.EmpID, tt.EmpID FROM abcde tt WHERE Type = 'Grid' GROUP BY tt.EmpID  
SELECT aa, aa FROM abcde tt WHERE Type = 'Grid' GROUP BY aa  
SELECT bb, bb FROM abcde tt WHERE Type = 'Grid' GROUP BY bb  
SELECT cc, cc FROM abcde tt WHERE Type = 'Grid' GROUP BY cc  

 
SQL Server | Other
{count} votes

2 answers

Sort by: Most helpful
  1. CathyJi-MSFT 22,396 Reputation points Microsoft External Staff
    2022-08-24T07:33:04.48+00:00

    Hi @Alan5896 ,

    Please use below T-SQL to check if any blocking.

    USE Master  
    GO  
    SELECT *   
    FROM sys.dm_exec_requests  
    WHERE blocking_session_id <> 0;  
    GO  
    

    Did you compare the execution plan between test and production environment.


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    1 person found this answer helpful.
    0 comments No comments

  2. Alan5896 26 Reputation points
    2022-08-24T13:26:53.987+00:00

    I ran the query -- empty table. Please see attached screenshot.

     ![USE Master  
     GO  
     SELECT *   
     FROM sys.dm_exec_requests  
     WHERE blocking_session_id <> 0;  
     GO][1]  
    
    1 person found this answer helpful.
    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.