Jonathan, thanks for looking at this. No, I haven't resolved it.
Client_Id is an integer column; there's an index on it:
CREATE NONCLUSTERED INDEX [Employees_Client_id] ON [dbo].[Employees]
(
[Client_ID] ASC,
[DivID] ASC,
[EmpID] ASC,
[Deleted] ASC
)
The query in question references both Client_Id and the bit column isadmin.
select count(*) from employees where client_id=11343 and isadmin=1
Since isadmin is not part of that index the query performs nested loop lookups of the clustered index. Here's the query plan.
|--Compute Scalar(DEFINE: ([Expr1003]=CONVERT_IMPLICIT(int,[Expr1008],0)))
|--Stream Aggregate(DEFINE: ([Expr1008]=Count(*)))
|--Filter(WHERE: ([phoenix].[dbo].[Employees].[IsAdmin]=(1)))
|--Nested Loops(Inner Join, OUTER REFERENCES: ([phoenix].[dbo].[Employees].[EmpID], [Expr1007]) WITH UNORDERED PREFETCH)
|--Index Seek(OBJECT: ([phoenix].[dbo].[Employees].[Employees_Client_id]), SEEK: ([phoenix].[dbo].[Employees].[Client_ID]=(11343)) ORDERED FORWARD)
|--Clustered Index Seek(OBJECT: ([phoenix].[dbo].[Employees].[PK_Employees]), SEEK: ([phoenix].[dbo].[Employees].[EmpID]=[phoenix].[dbo].[Employees].[EmpID]) LOOKUP ORDERED FORWARD)
I could add isadmin as an included column in the index which might or might not resolve the issue, but more importantly I want to understand just how one select query can block another. I didn't think that could happen. What could be getting locked?