<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>log space - Techyaz.com</title>
	<atom:link href="https://techyaz.com/tag/log-space/feed/" rel="self" type="application/rss+xml" />
	<link></link>
	<description>Tips, Tutorials and How-to Topics</description>
	<lastBuildDate>Sat, 28 Apr 2018 07:03:22 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.8.1</generator>

<image>
	<url>https://techyaz.com/wp-content/uploads/2017/11/cropped-Site-icon-150x150.png</url>
	<title>log space - Techyaz.com</title>
	<link></link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Fix Error 1105: Could not allocate space for object in database because the filegroup is full.</title>
		<link>https://techyaz.com/sql-server/troubleshooting/fix-error-1105/</link>
					<comments>https://techyaz.com/sql-server/troubleshooting/fix-error-1105/#respond</comments>
		
		<dc:creator><![CDATA[Manvendra Deo Singh]]></dc:creator>
		<pubDate>Mon, 16 Apr 2018 06:40:16 +0000</pubDate>
				<category><![CDATA[SQL Server Administration]]></category>
		<category><![CDATA[Troubleshooting]]></category>
		<category><![CDATA[HowTO]]></category>
		<category><![CDATA[log space]]></category>
		<category><![CDATA[space issues]]></category>
		<category><![CDATA[SQL_Error_Code]]></category>
		<category><![CDATA[T-SQL]]></category>
		<guid isPermaLink="false">http://techyaz.com/?p=2090</guid>

					<description><![CDATA[<p>Today, I got error 1105 on one of the database server. We were processing some bulk transactions on a database but failed because of space issue. Full description of error 1105 is given below. Error 1105, Severity 17, State 2&#46;&#46;&#46;</p>
<p>The post <a href="https://techyaz.com/sql-server/troubleshooting/fix-error-1105/">Fix Error 1105: Could not allocate space for object in database because the filegroup is full.</a> appeared first on <a href="https://techyaz.com">Techyaz.com</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>Today, I got error 1105 on one of the database server. We were processing some bulk transactions on a database but failed because of space issue. Full description of error 1105 is given below.</p>
<p><em><span style="color: #ff0000;">Error 1105, Severity 17, State 2</span></em><br />
<em><span style="color: #ff0000;"> Could not allocate space for object &#8216;Object_Name’ in database &#8216;DB_Name’ because the &#8216;Primary’ filegroup is full. Create disk space by deleting unneeded files, dropping objects in the filegroup, adding additional files to the filegroup, or setting autogrowth on for existing files in the filegroup.</span></em></p>
<h3><span style="color: #333399;">Error 1105 – Root Cause</span></h3>
<p>As error suggests, this issue was generated because database was not able to allocate space anymore. Whenever you get such space issue, all transactions will be stopped until you make some room in the database. All transactions will be stopped because of non availability of space because none of the transaction will get any space to proceed their transactions. There are many reasons you can get space issues. Some of them are:</p>
<p><img fetchpriority="high" decoding="async" class="size-full wp-image-2091 alignright" src="http://techyaz.com/wp-content/uploads/2018/04/Error-1105.png" alt="error 1105" width="300" height="300" srcset="https://techyaz.com/wp-content/uploads/2018/04/Error-1105.png 300w, https://techyaz.com/wp-content/uploads/2018/04/Error-1105-150x150.png 150w, https://techyaz.com/wp-content/uploads/2018/04/Error-1105-160x160.png 160w, https://techyaz.com/wp-content/uploads/2018/04/Error-1105-320x320.png 320w" sizes="(max-width: 300px) 100vw, 300px" /></p>
<ul>
<li>Data or Log drive is full.</li>
<li>Database file/s has restricted file growth</li>
<li>Database File Autogrowth is not enabled.</li>
<li>Some tables are growing faster than our prediction.</li>
<li>Some long running transaction is eating all space.</li>
</ul>
<p>We generally get error 1105 when any database including tempdb or any transaction log file get full and runs out of space. File growth restriction is also a possible reason you can get error 1105. Make sure to check all database files associated with your database to make sure there is no file growth restriction is set that is causing to generate this error. Sometimes when you restrict the file growth and the file size reached its limit, you may get this error message when trying insert / updates on database. I have explained multiple solutions to overcome this issue. Have a look at below section to get the solution of such space issues.</p>
<h3><span style="color: #333399;">Solution</span></h3>
<p>To fix this error we need to make space in the database so that all running transactions can execute and log their operations. We have multiple solutions to fix such issue based on the nature of the issues. Some of the solutions are given below:</p>
<ul>
<li>First you should check if any unwanted file is not there in data or log drive. Sometimes we placed backup files in data or log drive and forgot to delete it. Make sure to remove or move such unwanted files to make space for your database.</li>
<li>If any of the database files have restricted file growth then you should immediately turn on autogrow feature of the data or log file. You can read below article to understand what should be the perfect value for autogrowth of a data or log file.</li>
</ul>
<p style="padding-left: 90px;"><strong><u><a href="http://techyaz.com/sql-server/understanding-database-autogrowth-sql-server/" target="_blank" rel="noopener">How to Enable Autogrowth and What should be the Best value for File Autogrowth?</a></u></strong></p>
<ul>
<li>If size of your database file is limited to some value then make sure to extend the size of that file or I would suggest going with unrestricted growth. Read above attached article to get more about this.</li>
<li>If your data or log drive is running out of space then you should add more files to the file group on different drive where you have enough space. You can use below command to add any data or log file to your desired drive. Make sure to change the drive path as per your correct path.</li>
</ul>
<pre style="padding-left: 60px;"><strong><span style="color: #0000ff;">ALTER DATABASE Techyaz</span></strong>
<strong><span style="color: #0000ff;">ADD FILE (</span></strong>
<strong><span style="color: #0000ff;">NAME = techyaz_Data3,</span></strong>
<strong><span style="color: #0000ff;">FILENAME = 'F:\MSSQL\DATA\techyaz_DataFile3.ndf')</span></strong></pre>
<ul>
<li>We can also free disk space by dropping index or tables that are no longer needed. You can also consider data purging for unwanted tables or indexes.</li>
<li>You can also consider moving some of the database files to different drive to make some space for your database.</li>
</ul>
<p>I hope you like this article. Please follow our <a href="https://www.facebook.com/Techyaz/">Facebook</a> page and <a href="https://twitter.com/Tech_yaz">Twitter</a> handle to get latest updates.</p>
<p><span style="color: #800000;"><em><strong>Read More:</strong></em></span></p>
<ul>
<li><strong><a href="http://techyaz.com/sql-server/troubleshooting/fix-error-1101-could-not-allocate-a-new-page-for-database/" target="_blank" rel="noopener">Fix Error 1101: Could not allocate a new page for database</a></strong></li>
<li><strong><a href="http://techyaz.com/sql-server/avoid-database-shrink-operation/" target="_blank" rel="noopener">Why should we Avoid Database Shrink Operation?</a></strong></li>
<li><strong><a href="http://techyaz.com/sql-server/always-turn-off-database-auto-shrink/" target="_blank" rel="noopener">Why should we always Disable Autoshrink property?</a></strong></li>
</ul>
<p>The post <a href="https://techyaz.com/sql-server/troubleshooting/fix-error-1105/">Fix Error 1105: Could not allocate space for object in database because the filegroup is full.</a> appeared first on <a href="https://techyaz.com">Techyaz.com</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://techyaz.com/sql-server/troubleshooting/fix-error-1105/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Fix Error 1101: Could not allocate a new page for database</title>
		<link>https://techyaz.com/sql-server/troubleshooting/fix-error-1101-could-not-allocate-a-new-page-for-database/</link>
					<comments>https://techyaz.com/sql-server/troubleshooting/fix-error-1101-could-not-allocate-a-new-page-for-database/#respond</comments>
		
		<dc:creator><![CDATA[Manvendra Deo Singh]]></dc:creator>
		<pubDate>Fri, 23 Mar 2018 13:20:48 +0000</pubDate>
				<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SQL Server Administration]]></category>
		<category><![CDATA[Troubleshooting]]></category>
		<category><![CDATA[autogrow]]></category>
		<category><![CDATA[autogrowth setting]]></category>
		<category><![CDATA[data file autogrow]]></category>
		<category><![CDATA[data_files]]></category>
		<category><![CDATA[database property]]></category>
		<category><![CDATA[log space]]></category>
		<category><![CDATA[log_files]]></category>
		<category><![CDATA[space issues]]></category>
		<guid isPermaLink="false">http://techyaz.com/?p=1987</guid>

					<description><![CDATA[<p>We get error 1101 because of space issues. Database engine doesn’t able to allocate new pages to the database because of insufficient disk space. The error details are given below: Error: 1101, Severity: 17, State: 2 Could not allocate a&#46;&#46;&#46;</p>
<p>The post <a href="https://techyaz.com/sql-server/troubleshooting/fix-error-1101-could-not-allocate-a-new-page-for-database/">Fix Error 1101: Could not allocate a new page for database</a> appeared first on <a href="https://techyaz.com">Techyaz.com</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>We get error 1101 because of space issues. Database engine doesn’t able to allocate new pages to the database because of insufficient disk space. The error details are given below:</p>
<p><em><span style="color: #ff0000;">Error: 1101, Severity: 17, State: 2</span></em><br />
<em><span style="color: #ff0000;"> Could not allocate a new page for database ‘DBNAME&#8217; because of insufficient disk space in filegroup &#8216;PRIMARY&#8217;. Create the necessary space by dropping objects in the filegroup, adding additional files to the filegroup, or setting autogrowth on for existing files in the filegroup.</span></em></p>
<p>There is another error 1105 that is also very much like above error code. Error 1105 can also be fixed using same solution given in this article.</p>
<h3><span style="color: #333399;">Error 1101 &#8211; Root Cause</span></h3>
<p>Main reason behind error 1101 or error 1105 is the insufficient disk space in filegroup/files. You might also get this error if your database drives are running out of space. There are multiple reasons that can cause this error to generate. Some of them are given below.</p>
<ul>
<li>You have restricted database maximum file size or put size limits for files.</li>
<li>Database file drives are running out of space.</li>
<li>Autogrowth is not enabled for database files.</li>
</ul>
<h3><span style="color: #333399;">Solutions</span></h3>
<p>To fix this issue we need to make space for database files to grow. Issue might vary depending on the nature of issue mentioned in above section. Sometimes, you might face this issue if maximum size for database files are restricted to some values so whenever database will grow to that point, SQL Server will not allow to allocate any page to that database. Sometimes you might get error 1101 because you don’t have any space on your database drives. Here, I will discuss each case individually and its solution to fix it.</p>
<h5><span style="color: #993300;">Unrestrict or Increase Database File Size Limits</span></h5>
<p>You might have enough space in your database drives but still you can get error 1101 because the maximum file size of database files is limited to some value and that causes not to grow your database beyond that size. You can unrestrict or increase the existing value of maximum file size to some bigger value. We have also an option to set database file size to unlimited size value that means database file will grow till the database file drive limit. Make sure to set appropriate autogrowth size for each database files.</p>
<p>You can set unlimited file size option or increase the value of maximum file size using GUI in SQL Server Management Studio or using ALTER statement.</p>
<ul>
<li>Connect to Database Instance in <strong>SQL Server Management Studio</strong>. Expand <strong>Database</strong> folder.</li>
<li>Right Click on your database and choose <strong>Property window</strong>.</li>
<li>Click on <strong>Files</strong> tab from left side pane in database property window.</li>
<li>Here you can see all database files. Now you can click on three dots given next of database files in “Autogrowth/Maxsize” column. You can see max size is set to a limited value as shown in below screenshot. I have chosen unlimited option and clicked on Ok button.</li>
</ul>
<p><img decoding="async" class="aligncenter wp-image-1991 size-full" src="http://techyaz.com/wp-content/uploads/2018/03/1-SizeLimit-min.jpg" alt="Set Database file size to unlimited" width="394" height="314" srcset="https://techyaz.com/wp-content/uploads/2018/03/1-SizeLimit-min.jpg 394w, https://techyaz.com/wp-content/uploads/2018/03/1-SizeLimit-min-300x239.jpg 300w" sizes="(max-width: 394px) 100vw, 394px" /></p>
<p>Now we will not get any issue if our database drive has enough space.</p>
<h5><span style="color: #993300;">Space in Database Drives</span></h5>
<p>Another possibility for this error is, there might be possibility that your drives on which you have placed your database files are running out of space. If this is the case then you have below 4 options.</p>
<ul>
<li>Add additional database file to different disk where there is enough space.</li>
<li>Move additional/unwanted files from your existing database drives.</li>
<li>Drop/Purge or Move unwanted data (table/indexes)</li>
<li>Add Additional Disk Space</li>
</ul>
<p>Immediate fix of this issue is to add new database file to another drive where you have enough space to run your transactions. You can use below command to add addition database file to another disk.</p>
<pre><strong><span style="color: #0000ff;">USE [master]</span></strong>
<strong><span style="color: #0000ff;">GO</span></strong>
<strong><span style="color: #0000ff;">ALTER DATABASE [DBNAME]</span></strong>
<strong><span style="color: #0000ff;">ADD FILE (NAME = N'NewFileName', FILENAME = N'F:\mssql\data\newdatafile.ndf', SIZE = 100096KB, FILEGROWTH = 10240KB)</span></strong>
<strong><span style="color: #0000ff;">TO FILEGROUP [SECONDARY]</span></strong>
<strong><span style="color: #0000ff;">GO</span></strong></pre>
<p>You can also add new database file in SQL Server Management Studio by launching Database Property Window. Select Files from left side pane and Click on “Add” button showing in below screenshot. Make sure to set autogrowth value carefully for any database file. Also it is recommended to enable IFI – Instant File Initialization to speed up autogrowth process for your databases. Refer to below article to get best value for autogrowth for your database files. You can also read what are the benefits and how to enable IFI &#8211; Instant File Initialization in below article.</p>
<ul>
<li><strong><a href="http://techyaz.com/sql-server/understanding-database-autogrowth-sql-server/" target="_blank" rel="noopener">What Should be the Best Value for database Autogrowth settings?</a></strong></li>
<li><strong><a href="http://techyaz.com/sql-server/instant-file-initialization-enable-on-sql-server-instance/" target="_blank" rel="noopener">How to Enable Instant File Initialization in SQL Server?</a></strong></li>
</ul>
<p><img decoding="async" class="aligncenter wp-image-1993 size-full" src="http://techyaz.com/wp-content/uploads/2018/03/2-SizeLimit.jpg" alt="Add database file using GUI" width="705" height="633" srcset="https://techyaz.com/wp-content/uploads/2018/03/2-SizeLimit.jpg 705w, https://techyaz.com/wp-content/uploads/2018/03/2-SizeLimit-300x269.jpg 300w" sizes="(max-width: 705px) 100vw, 705px" /></p>
<p>You can also have a look at the existing database drives whether there is any unwanted files or older backup files (*.bak) are not stored. Sometimes we run backups into database drives and forgot to delete or move them. Make sure to drop or move all unwanted files to some other location. Database drives should have only database files.</p>
<p>Final and long-term solution is the data purging. Identify the database objects that are not needed and then plan the data removal or data purging process to make space on your database.</p>
<p>We also have an option to extend the database drives as per the data growth. Make sure to plan this activity carefully before deploying it on production servers.</p>
<h5><span style="color: #993300;">Enable Autogrowth</span></h5>
<p>I have already written an article on Database autogrowth property setting. Read attached article to <a href="http://techyaz.com/sql-server/understanding-database-autogrowth-sql-server/" target="_blank" rel="noopener">find out best value for Autogrowth settings</a>.</p>
<p>You might get error 1101 if you have not enabled authogrowth setting for your database files. You need to enable it by launching database property window. You can click on three dots next to each database files in column “Authogrowth/Maxsize” and click at the enable authogrowth checkbox as showing in below screenshot.</p>
<p><img loading="lazy" decoding="async" class="size-full wp-image-1994 aligncenter" src="http://techyaz.com/wp-content/uploads/2018/03/3-Autogrowth-min.jpg" alt="Enable Autogrowth" width="701" height="631" srcset="https://techyaz.com/wp-content/uploads/2018/03/3-Autogrowth-min.jpg 701w, https://techyaz.com/wp-content/uploads/2018/03/3-Autogrowth-min-300x270.jpg 300w" sizes="auto, (max-width: 701px) 100vw, 701px" /></p>
<p>You can also use ALTER statement to enable database autogrowth setting for your database file. Remember, you need to run this ALTER statement for each database file separately.</p>
<p>Run below ALTER command to enable autogrowth for database file.</p>
<pre><span style="color: #008000;"><strong>--Pass logical filename of your database file for under NAME section.</strong></span>
<span style="color: #0000ff;"><strong>ALTER DATABASE [Techyaz] MODIFY FILE ( NAME = N'Techyaz_Data', FILEGROWTH = 10000KB )</strong></span></pre>
<p>Make sure to enable Instant File Initialization to speedup autogrowth operations. Links to enable Instant File Initialization is attached in this article.</p>
<p>If you are facing this issue for tempdb database then you can consider one more option apart from all of the above options. And this option is to restart SQL Server service if it&#8217;s allowed. Keep in mind, SQL Server service restart will cause an outage for few minutes but it will create new tempdb files with initial size and error 1101 will be disappeared. This is not recommended solution because of outage so you should work on long terms solutions.</p>
<p>You can also use above solutions to fix error 1105 that is very much similar to error 1101. I hope you like this article. Please follow our <a href="https://www.facebook.com/Techyaz/">Facebook</a> page and <a href="https://twitter.com/Tech_yaz">Twitter</a> handle to get latest updates.</p>
<p><span style="color: #800000;"><em><strong>Read More:</strong></em></span></p>
<ul>
<li><strong><a href="http://techyaz.com/sql-server/troubleshooting/fix-msg-5144-and-5145-for-long-or-failed-autogrow/" target="_blank" rel="noopener">Fix Error 5144 and Error 5145 for Long or Failed Autogrow of Database Files</a></strong></li>
<li><strong><a href="http://techyaz.com/sql-server/understanding-database-autogrowth-sql-server/" target="_blank" rel="noopener">Understanding Autogrowth Operation in SQL Server Databases</a></strong></li>
<li><strong><a href="http://techyaz.com/sql-server/instant-file-initialization-enable-on-sql-server-instance/" target="_blank" rel="noopener">How to Enable IFI &#8211; Instant File Initialization?</a></strong></li>
<li><strong><a href="http://techyaz.com/sql-server/troubleshooting/manage-transaction-log-file-during-data-load/" target="_blank" rel="noopener">Manage Database Files during huge Data Load</a></strong></li>
</ul>
<p>The post <a href="https://techyaz.com/sql-server/troubleshooting/fix-error-1101-could-not-allocate-a-new-page-for-database/">Fix Error 1101: Could not allocate a new page for database</a> appeared first on <a href="https://techyaz.com">Techyaz.com</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://techyaz.com/sql-server/troubleshooting/fix-error-1101-could-not-allocate-a-new-page-for-database/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>4 Different Usages of DBCC SQLPERF in SQL Server</title>
		<link>https://techyaz.com/sql-server/sql-server-dmvs/4-different-usages-dbcc-sqlperf-sql-server/</link>
					<comments>https://techyaz.com/sql-server/sql-server-dmvs/4-different-usages-dbcc-sqlperf-sql-server/#respond</comments>
		
		<dc:creator><![CDATA[Manvendra Deo Singh]]></dc:creator>
		<pubDate>Mon, 08 Jan 2018 11:02:31 +0000</pubDate>
				<category><![CDATA[DBCC & DMVs]]></category>
		<category><![CDATA[Performance Tuning]]></category>
		<category><![CDATA[Wait Types]]></category>
		<category><![CDATA[DBCC]]></category>
		<category><![CDATA[dmv]]></category>
		<category><![CDATA[latches]]></category>
		<category><![CDATA[log space]]></category>
		<category><![CDATA[log_files]]></category>
		<category><![CDATA[transaction log]]></category>
		<category><![CDATA[wait statistics]]></category>
		<category><![CDATA[Waittypes]]></category>
		<guid isPermaLink="false">http://techyaz.com/?p=1445</guid>

					<description><![CDATA[<p>DBCC SQLPERF is very useful command that we use to get multiple statistics related information in SQL Server. This command provides transaction log space statistics and wait statistics information at instance level and we also use it to reset wait and&#46;&#46;&#46;</p>
<p>The post <a href="https://techyaz.com/sql-server/sql-server-dmvs/4-different-usages-dbcc-sqlperf-sql-server/">4 Different Usages of DBCC SQLPERF in SQL Server</a> appeared first on <a href="https://techyaz.com">Techyaz.com</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>DBCC SQLPERF is very useful command that we use to get multiple statistics related information in SQL Server. This command provides <a href="http://techyaz.com/sql-server/understanding-transaction-log-architecture/" target="_blank" rel="noopener">transaction log</a> space statistics and wait statistics information at instance level and we also use it to reset wait and latch statistics data. We can use DBCC SQLPERF command to do below tasks.</p>
<ol>
<li>Get log space size</li>
<li>View wait statistics data</li>
<li>Clear wait statistics data</li>
<li>Clear latch statistics data</li>
</ol>
<p>Let’s discuss each of above tasks as use cases of DBCC SQLPERF command.</p>
<p><em><strong><span style="color: #800000;">Read More</span></strong></em></p>
<ul>
<li><a href="http://techyaz.com/sql-server/get-total-virtual-log-files/" target="_blank" rel="noopener">How to get total no of VLFs (Virtual Log Files) inside Log file?</a></li>
<li><a href="http://techyaz.com/sql-server/understanding-sql-server-data-files-pages-extents/" target="_blank" rel="noopener">Understanding Data Files, Pages &amp; Extents</a></li>
<li><a href="http://techyaz.com/sql-server/how-to-avoid-page-split-in-sql-server/" target="_blank" rel="noopener">How to Avoid Page Split in SQL Server?</a></li>
</ul>
<h4><span style="color: #333399;">Get Transaction Log space using DBCC SQLPERF</span></h4>
<p>We can get transaction log space utilization details like how large your transaction logs are and what percentage of them is in use by executing dbcc sqlperf command. Run below command to get the log space details of all database hosted your SQL Server Instance.</p>
<div class="codediv">
<pre><strong><span style="color: #008000;">--Get Transaction Log Size Details</span>
<span style="color: #0000ff;">DBCC SQLPERF(logspace)
</span></strong></pre>
</div>
<p>You can see the below screenshot; all the columns are self-explanatory. We can see percent of log space used out of total space allocated to the log file.</p>
<p><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-1447" src="http://techyaz.com/wp-content/uploads/2018/01/1-Check-log-space.jpg" alt="Check Log space utilization using dbcc sqlperf" width="417" height="236" srcset="https://techyaz.com/wp-content/uploads/2018/01/1-Check-log-space.jpg 417w, https://techyaz.com/wp-content/uploads/2018/01/1-Check-log-space-300x170.jpg 300w" sizes="auto, (max-width: 417px) 100vw, 417px" /></p>
<h4><span style="color: #333399;">View and Clear Wait Statistics Data</span></h4>
<p>We can get wait statistics data using dbcc sqlperf command as well. We used to get these details using dbcc sqlperf command in older version of SQL Server instances. Although, you can still get wait statistics data using this command in current versions of SQL Server but now there is a better way to get such details using DMV <strong>sys.dm_os_wait_stats</strong>.  Here, I will show you wait stats data using DMV only. Run below commands to get wait statistics details of your SQL Server instance.</p>
<div class="codediv">
<pre><strong><span style="color: #008000;">--Get wait Statistics using DBCC command.</span>
DBCC SQLPERF(waitstats)

<span style="color: #008000;">--Get Wait Statistics using DMV sys.dm_os_wait_stats</span>
SELECT * FROM sys.dm_os_wait_stats
Order by wait_time_ms desc
</strong></pre>
</div>
<p>You can see the details about all wait types on your SQL Server instance. You can also see the total wait time in milliseconds. These information is very important to deal with performance issues but details like total wait time, total waiting tasks count are not the real-time values. These values are accumulated since last SQL Server service start or last time wait stats was reset using dbcc sqlperf command. It is highly recommended to not clear wait stats data until it is required to do that otherwise you will lose valuable information about wait statistics. Read attached article about <a href="http://techyaz.com/sql-server/sql-server-dmvs/clear-wait-statistics-data-sql-server/" target="_blank" rel="noopener">why should you not clear wait statistics data stored in DMV sys.dm_os_wait_stats</a>.</p>
<p><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-1448" src="http://techyaz.com/wp-content/uploads/2018/01/2-sys.dm_os_wait_stats.jpg" alt="View Wait stats data using DMV" width="643" height="300" srcset="https://techyaz.com/wp-content/uploads/2018/01/2-sys.dm_os_wait_stats.jpg 643w, https://techyaz.com/wp-content/uploads/2018/01/2-sys.dm_os_wait_stats-300x140.jpg 300w" sizes="auto, (max-width: 643px) 100vw, 643px" /></p>
<p>If you want to get the correct waiting task counts or waiting time then you need to clear the wait statistics data using dbcc sqlperf command. Here, I will show you the difference after clearing the wait stats. Run below command to clear all wait stats data on your SQL Server Instance.</p>
<div class="codediv">
<pre><strong>DBCC SQLPERF(“sys.dm_os_wait_stats”, CLEAR)
</strong></pre>
</div>
<p>You can see I have successfully ran this command in below screenshot.</p>
<p><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-1449" src="http://techyaz.com/wp-content/uploads/2018/01/3-Clear-buffer-for-wait-stats.jpg" alt="clear wait stats" width="689" height="121" srcset="https://techyaz.com/wp-content/uploads/2018/01/3-Clear-buffer-for-wait-stats.jpg 689w, https://techyaz.com/wp-content/uploads/2018/01/3-Clear-buffer-for-wait-stats-300x53.jpg 300w" sizes="auto, (max-width: 689px) 100vw, 689px" /></p>
<p>Now we will again run same command to get the wait statistics data. I ran it and I get below data that is showing different than the one showing before clearing wait stats. This way you can better analyze your database performance and waiting tasks and time to reach on any conclusion.</p>
<p><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-1450" src="http://techyaz.com/wp-content/uploads/2018/01/4-Check-wait-stats-after-clearning-buffer.jpg" alt="Check wait stats after clearing its buffer" width="804" height="283" srcset="https://techyaz.com/wp-content/uploads/2018/01/4-Check-wait-stats-after-clearning-buffer.jpg 804w, https://techyaz.com/wp-content/uploads/2018/01/4-Check-wait-stats-after-clearning-buffer-300x106.jpg 300w, https://techyaz.com/wp-content/uploads/2018/01/4-Check-wait-stats-after-clearning-buffer-768x270.jpg 768w" sizes="auto, (max-width: 804px) 100vw, 804px" /></p>
<p>&nbsp;</p>
<h4><span style="color: #333399;">Clear Latch Statistics Data</span></h4>
<p>I described about clearing wait stats data in above section. Here, I will show you how to clear latch statistics data. <b>Latches</b> are locks for RAM memory structures to prevent concurrent access and ensure serial execution of kernel code. You can run SQL command to check current latch statistics data.</p>
<div class="codediv">
<pre><span style="color: #008000;"><span style="color: #008000;"><b>--Get latch statistics data</b></span></span><b>
SELECT * FROM sys.dm_os_latch_stats
ORDER BY wait_time_ms desc
</b></pre>
</div>
<p>You can see current latch statistics details that is also not showing only real time value but it is accumulated data since last SQL Server service restarted or last time latch wait statistics was reset/cleared.</p>
<p><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-1451" src="http://techyaz.com/wp-content/uploads/2018/01/5-Check-Latch.jpg" alt="Get Latch Statistics Data" width="678" height="217" srcset="https://techyaz.com/wp-content/uploads/2018/01/5-Check-Latch.jpg 678w, https://techyaz.com/wp-content/uploads/2018/01/5-Check-Latch-300x96.jpg 300w" sizes="auto, (max-width: 678px) 100vw, 678px" /></p>
<p>&nbsp;</p>
<p>Now we will clear these latch statistics data to get real time value of latch details. Run below dbcc sqlperf command to clear the latch statistics.</p>
<div class="codediv">
<pre><strong>DBCC SQLPERF(“sys.dm_os_latch_stats”, CLEAR)
</strong></pre>
</div>
<p>You can see we have successfully executed above command on our SQL Server Instance.</p>
<p><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-1452" src="http://techyaz.com/wp-content/uploads/2018/01/6-Clear-stored-latch-details.jpg" alt="Clear Latch Statistics Data" width="722" height="121" srcset="https://techyaz.com/wp-content/uploads/2018/01/6-Clear-stored-latch-details.jpg 722w, https://techyaz.com/wp-content/uploads/2018/01/6-Clear-stored-latch-details-300x50.jpg 300w" sizes="auto, (max-width: 722px) 100vw, 722px" /></p>
<p>Now go ahead and run same SQL command to get the latch statistics again. You can see now there is no waiting requests on our SQL Server Instance and you are getting real time value about latches.</p>
<p><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-1453" src="http://techyaz.com/wp-content/uploads/2018/01/7-check-latch-details-after-clearning-buffer.jpg" alt="latch details after cleaning its buffer data " width="677" height="197" srcset="https://techyaz.com/wp-content/uploads/2018/01/7-check-latch-details-after-clearning-buffer.jpg 677w, https://techyaz.com/wp-content/uploads/2018/01/7-check-latch-details-after-clearning-buffer-300x87.jpg 300w" sizes="auto, (max-width: 677px) 100vw, 677px" /></p>
<p><em><strong><span style="color: #800000;">Related Articles</span></strong></em></p>
<ul>
<li><a href="http://techyaz.com/sql-server/sql-server-dmvs/clear-wait-statistics-data-sql-server/" target="_blank" rel="noopener">Should We Clear Wait Stats Data from DMV sys.dm_os_wait_stats?</a></li>
<li><a href="http://techyaz.com/sql-server/backupbuffer-wait-type/" target="_blank" rel="noopener">How to Fix BACKUPBUFFER Wait Type?</a></li>
<li><a href="http://techyaz.com/sql-server/improve-sql-server-bulk-data-import-performance/" target="_blank" rel="noopener">How to Improve Bulk Data Load Performance?</a></li>
</ul>
<p>These are the 4 use cases of DBCC SQLPERF command that we use during different database activities. I hope you like this article. Please follow our <a href="https://www.facebook.com/Techyaz/">Facebook</a> page and <a href="https://twitter.com/Tech_yaz">Twitter </a>handle to get latest updates.</p>
<p>The post <a href="https://techyaz.com/sql-server/sql-server-dmvs/4-different-usages-dbcc-sqlperf-sql-server/">4 Different Usages of DBCC SQLPERF in SQL Server</a> appeared first on <a href="https://techyaz.com">Techyaz.com</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://techyaz.com/sql-server/sql-server-dmvs/4-different-usages-dbcc-sqlperf-sql-server/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
