Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 Cancelling Query taking a long time

Author  Topic 

denis_the_thief
Aged Yak Warrior

596 Posts

Posted - 2011-10-06 : 11:16:09
Why can it take so long to cancel a query? I ran a select statement through Management Studio and it hangs saying 'Cancelling Query'. If it was rolling back I could see it but for a select statment?

theboyholty
Posting Yak Master

226 Posts

Posted - 2011-10-06 : 11:52:40
Can I suggest you post your code?

---------------------------------------------------------------------------------
http://www.mannyroadend.co.uk A Bury FC supporters website and forum
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-10-06 : 12:10:35
it may be an intensive transaction you executed and it needs to rollback all applied changes

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

denis_the_thief
Aged Yak Warrior

596 Posts

Posted - 2011-10-06 : 13:20:01
quote:
Originally posted by visakh16

it may be an intensive transaction you executed and it needs to rollback all applied changes

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/





This one was a select only. It was slow to begin with. But I was just surprised cancellinging would take so long...
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-10-06 : 13:22:42
select itself will take long time to get cancelled if amount of data its retrieving is very large.

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

denis_the_thief
Aged Yak Warrior

596 Posts

Posted - 2011-10-06 : 13:36:50
quote:
Originally posted by visakh16

select itself will take long time to get cancelled if amount of data its retrieving is very large.




Yes, in this case lots of data, over a network. That's what I don't get, why can't it just stop what it's doing.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-10-06 : 13:38:04
it will stop once it has done with rollback of what it was doing

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

denis_the_thief
Aged Yak Warrior

596 Posts

Posted - 2011-10-06 : 13:52:33
quote:
Originally posted by visakh16

it will stop once it has done with rollback of what it was doing

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/





But what would it need to roll back if it is a Select only?

I guess read locks but this one had very few records and only one table.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-10-06 : 13:59:07
you never knew. if you're using some functions like ROW_NUMBER() etc it will internally do sorting for which it uses internal temporary tables etc

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -