This article is half-done without your Comment! *** Please share your thoughts via Comment ***
In this post, I am sharing a script to perform PINTABLE and UNPINTABLE in SQL Server.
Using PINTABLE, we can keep data in the data cache of SQL Server which boosts the speed of query execution.
Once you PINTABLE in the data cache, it doesn’t load the whole table but it keeps only required a portion of the table.
If you have enough size of the data cache, you can try this option for a frequently used table.
SQL Server Interview: How internally it executes a SQL Statement?
PINTABLE:
1 2 3 4 |
DECLARE @DBID INT, @TableID INT SET @DBID = DB_ID('DatabaseName') SET @TableID = OBJECT_ID('DatabaseName.SchemaName.TableName') DBCC PINTABLE (@DBID, @TableID) |
UNPINTABLE:
1 2 3 4 |
DECLARE @DBID INT, @TableID INT SET @DBID = DB_ID('DatabaseName') SET @TableID = OBJECT_ID('DatabaseName.SchemaName.TableName') DBCC UNPINTABLE (@DBID, @TableID) |
Leave a Reply