Breaking News
Loading...
20/10/2013

Hiểu nhầm về Table variable trong SQL Server

Nhiều người nghĩ rằng Table Variable được lưu trên memory, thật ra nó được lưu trong Tempdb.

Ta có thể chứng minh điều này bằng cách dùng đoạn script sau:

DECLARE @TempTable TABLE ( ID INT ) ;
INSERT INTO @TempTable ( ID )
VALUES ( 1 ) ;
GO
SELECT session_id,
database_id,
user_objects_alloc_page_count
FROM sys.dm_db_session_space_usage
WHERE session_id > 50 ;

nếu thấy database ID=2 tức là table variable đã được lưu ở Tempdb.

Theo ebook: SQL internal and troubleshooting

0 comments:

Post a Comment

 
Toggle Footer