English 中文(简体)
tempdb SQL Server locking
原标题:

Our application runs alongside another application on a customers machine. We have put some efforts regarding avoiding long-running locks in tempdb since this obviously affects concurrency badly. The other application, however does things like:


begin transaction
create #Table(...);
insert into #Table(....) values(...);
operation_for_totally_six_seconds().
commit;

Since the operations take time, our application get stuck waiting for the locks aquired by the other application.

Now, I expect there to be a way to isolate my application from the other application by for example telling sql server to assign me another tempdb, but I have not found a way. Is this somehow possible or is the solution to install our database on another mssql-instance?

Regards, Jens Nordenbro

问题回答

long-running locks in tempdb since this obviously affects concurrency badly

That is actually not obvious at all. Long held locks are of importance only if you and the other application go after the same locks. The code sample you posted is perfectly legitimate. First of all #temp is a connection specific table that no other connection can even see it. But even if it would be global resource, it would belong to the other application and hence you would have no business acquiring locks on it.

As an exercise, open an SSMS query window and run this:

begin transaction;
create table #temp (a int);

Then opne a second query window and run the same. QED they don t block each other, despite creating the very same #temp table.

If tempdb is indeed a bottle neck you need to do some more investigation and find the actual resources that contention occurs on.

One option is to run your app in a different instance of sql server on the same machine. This way you would have your own tempdb.





相关问题
Export tables from SQL Server to be imported to Oracle 10g

I m trying to export some tables from SQL Server 2005 and then create those tables and populate them in Oracle. I have about 10 tables, varying from 4 columns up to 25. I m not using any constraints/...

SQL server: Can NT accounts be mapped to SQL server accounts

In our database we have an SQL server account that has the correct roles to access some of the databases. We are now switching to windows authentication and I was wondering if we can create a NT user ...

SQL Server 2000, ADO 2.8, VB6

How to determine if a Transaction is active i.e. before issuing Begin Transaction I want to ensure that no previous transaction are open.. the platform is VB6, MS-SQL Server 2000 and ADO 2.8

热门标签