Puedes ver los bloqueos por ti mismo con el flag de traza 1200; trátalo como una herramienta de máquina de desarrollo, ya que es global:
SET NOCOUNT ON; CREATE TABLE ##T ( X INT ) INSERT INTO ##T SELECT number FROM master..spt_values CREATE TABLE #T ( X INT ) INSERT INTO #T SELECT * FROM ##T /*Run the commands first with the trace flag off so the locking info is less full of irrelevant stuff about plan compilation */ GO PRINT '##T Read Committed' SELECT COUNT(*) FROM ##T PRINT '##T NOLOCK' SELECT COUNT(*) FROM ##T WITH (NOLOCK) PRINT '##T Finished' GO PRINT '#T Read Committed' SELECT COUNT(*) FROM #T PRINT '#T NOLOCK' SELECT COUNT(*) FROM #T WITH (NOLOCK) PRINT '#T Finished' GO DBCC TRACEON(-1,3604) DBCC TRACEON(-1,1200) GO PRINT '##T Read Committed' SELECT COUNT(*) FROM ##T PRINT '##T NOLOCK' SELECT COUNT(*) FROM ##T WITH (NOLOCK) PRINT '##T Finished' GO PRINT '#T Read Committed' SELECT COUNT(*) FROM #T PRINT '#T NOLOCK' SELECT COUNT(*) FROM #T WITH (NOLOCK) PRINT '#T Finished' GO DBCC TRACEOFF(-1,3604) DBCC TRACEOFF(-1,1200) DROP TABLE ##T DROP TABLE #T Para una tabla temporal global la diferencia es, como era de esperar, mucho más pronunciada.
Incluso para una tabla temporal local #temp hay una pequeña diferencia en el tipo de bloqueo. Esa porción de la salida:
#T Read Committed Process 56 acquiring IS lock on OBJECT: 2:301244128:0 (class bit0 ref1) result: OK Process 56 acquiring S lock on OBJECT: 2:301244128:0 (class bit0 ref1) result: OK Process 56 releasing lock on OBJECT: 2:301244128:0 #T NOLOCK Process 56 acquiring Sch-S lock on OBJECT: 2:301244128:0 (class bit0 ref1) result: OK Process 56 acquiring S lock on HOBT: 2:9079256880114171904 [BULK_OPERATION] (class bit0 ref1) result: OK Process 56 releasing lock on OBJECT: 2:301244128:0 Edición: lo anterior es para un heap. Con un índice clustered en la tabla temporal, los resultados son:
#T Read Committed Process 55 acquiring IS lock on OBJECT: 2:1790629422:0 (class bit0 ref1) result: OK Process 55 acquiring S lock on OBJECT: 2:1790629422:0 (class bit0 ref1) result: OK Process 55 releasing lock on OBJECT: 2:1790629422:0 #T NOLOCK Process 55 acquiring Sch-S lock on OBJECT: 2:1790629422:0 (class bit0 ref1) result: OK Process 55 releasing lock on OBJECT: 2:1790629422:0 #T Finished El bloqueo BULK_OPERATION en la variante heap está explicado aquí. En cualquier caso, la sobrecarga de bloqueo de una tabla temporal local es mínima, así que NOLOCK no te aporta prácticamente nada.