﻿<?xml version='1.0' encoding='UTF-8'?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>SQLServerCentral / Article Discussions / Article Discussions by Author / Discuss content posted by Wayne Sheffield  / Ghost Cleanup / Latest Posts</title><generator>InstantForum.NET v2.9.0</generator><description>SQLServerCentral</description><link>http://www.sqlservercentral.com/Forums/</link><webMaster>notifications@sqlservercentral.com</webMaster><lastBuildDate>Tue, 21 May 2013 12:21:48 GMT</lastBuildDate><ttl>20</ttl><item><title>RE: Ghost Cleanup</title><link>http://www.sqlservercentral.com/Forums/Topic1407016-1273-1.aspx</link><description>pure technical questionagain something which full brain with no real interest, interesting though</description><pubDate>Fri, 22 Feb 2013 01:17:43 GMT</pubDate><dc:creator>jfgoude</dc:creator></item><item><title>RE: Ghost Cleanup</title><link>http://www.sqlservercentral.com/Forums/Topic1407016-1273-1.aspx</link><description>Good question, and the reference in the explanation is useful.I answered it correctly because I remembered that a table keeps its pages until the index thy are a component of is dropped, rebuilt (or defragmented?) or the table is dropped (or truncated), so the number wasn't going to go down and there was nothing that could cause it to go up - perhaps that's a simpler way to think of it than worrying about low level stuff in the storage model.</description><pubDate>Fri, 18 Jan 2013 13:57:22 GMT</pubDate><dc:creator>L' Eomot Inversé</dc:creator></item><item><title>RE: Ghost Cleanup</title><link>http://www.sqlservercentral.com/Forums/Topic1407016-1273-1.aspx</link><description>[quote][b]Sean Lange (1/15/2013)[/b][hr]Great question Wayne. I knew the page would not be deallocated but I didn't know all of the details. The article was very interesting and informative read.I wonder if Celko will start bashing Paul Randal for calling them records instead of rows?? :-D[/quote]I doubt it, because I'm sure that Joe recognizes that "record" is the right name for something deep down in the data engine, way below the relational model, and that's what Paul is talking about here - a string of bits somewhere on a disc (or on a cached copy of part of a disc) not a row in the relational model.  The relation no longer contains that row once the transaction is committed, but its storage container will contains the record until the cleanup task or index defragmentation or rebuilding removes it, and that can be a long time after the transactio is committed - that's how we know that this is a record not a row.</description><pubDate>Fri, 18 Jan 2013 11:33:37 GMT</pubDate><dc:creator>L' Eomot Inversé</dc:creator></item><item><title>RE: Ghost Cleanup</title><link>http://www.sqlservercentral.com/Forums/Topic1407016-1273-1.aspx</link><description>[quote][b]WayneS (1/15/2013)[/b][hr][quote][b]okbangas (1/15/2013)[/b][hr]As far as I understand it, there is something missing from the explanation. If we assume that only what's  written in the scenario has happened, the scenario is as follows:* Table is created* Records are inserted* Records are deleted -&amp;gt; Marked as ghost* Ghost Cleanup Task is running (every 5 seconds).But, there has not been any scan between the marking of ghost records and Ghost Cleanup Task, hence it has nothing to do.[quote]The ghost cleanup task doesn't just start up when it's told to – it starts up in the background every 5 seconds and looks for ghost records to cleanup. Remember that it won't be told to go cleanup a specific page by a delete operation – it's a subsequent scan that does it, if a scan happens.[/quote] [url=http://www.sqlskills.com/blogs/paul/inside-the-storage-engine-ghost-cleanup-in-depth/]http://www.sqlskills.com/blogs/paul/inside-the-storage-engine-ghost-cleanup-in-depth/[/url][/quote]You're absolutely correct. However, the question states:[quote]If you delete the first 12 records, how many data pages will the table have [b][i]after[/i][/b] the Ghost Cleanup process has been run against this table?[/quote] It's not going to run against this table until something scans this table, but once it does, it will leave that page with only one record in it.[/quote]If the cleanup process doesn't have any pages it's been told by scans to do, doesn't it use the PFS map to find pages to do?  And isn't the PFS map marked by the delete operation, not by a subsequent scan?</description><pubDate>Fri, 18 Jan 2013 11:23:59 GMT</pubDate><dc:creator>L' Eomot Inversé</dc:creator></item><item><title>RE: Ghost Cleanup</title><link>http://www.sqlservercentral.com/Forums/Topic1407016-1273-1.aspx</link><description>Thanks for a really interresting question - it forced me to do some digging.</description><pubDate>Wed, 16 Jan 2013 13:22:45 GMT</pubDate><dc:creator>Revenant</dc:creator></item><item><title>RE: Ghost Cleanup</title><link>http://www.sqlservercentral.com/Forums/Topic1407016-1273-1.aspx</link><description>Great question -- I wasn't even aware there WAS such a thing as the Ghost function. The question forced me to do some research -- thanks!</description><pubDate>Wed, 16 Jan 2013 09:31:15 GMT</pubDate><dc:creator>Rob Schripsema</dc:creator></item><item><title>RE: Ghost Cleanup</title><link>http://www.sqlservercentral.com/Forums/Topic1407016-1273-1.aspx</link><description>Great Question...Thanks..</description><pubDate>Wed, 16 Jan 2013 09:03:05 GMT</pubDate><dc:creator>pchirags</dc:creator></item><item><title>RE: Ghost Cleanup</title><link>http://www.sqlservercentral.com/Forums/Topic1407016-1273-1.aspx</link><description>Thanks for the question.  I learned something about ghost cleanup.</description><pubDate>Wed, 16 Jan 2013 05:04:27 GMT</pubDate><dc:creator>(Bob Brown)  </dc:creator></item><item><title>RE: Ghost Cleanup</title><link>http://www.sqlservercentral.com/Forums/Topic1407016-1273-1.aspx</link><description>Nice question...</description><pubDate>Wed, 16 Jan 2013 02:18:05 GMT</pubDate><dc:creator>Anipaul</dc:creator></item><item><title>RE: Ghost Cleanup</title><link>http://www.sqlservercentral.com/Forums/Topic1407016-1273-1.aspx</link><description>Hmmm, very interesting questions..</description><pubDate>Wed, 16 Jan 2013 02:15:18 GMT</pubDate><dc:creator>Bangla</dc:creator></item><item><title>RE: Ghost Cleanup</title><link>http://www.sqlservercentral.com/Forums/Topic1407016-1273-1.aspx</link><description>[quote][b]Sean Lange (1/15/2013)[/b][hr]Great question Wayne. I knew the page would not be deallocated but I didn't know all of the details. The article was very interesting and informative read.I wonder if Celko will start bashing Paul Randal for calling them records instead of rows?? :-D[/quote]Actually, if you want to be pedantic, [i]records[/i] is the correct term here, because we're talking about the physical storage. [i]Rows[/i] refers to the logical model. :cool:</description><pubDate>Tue, 15 Jan 2013 09:48:41 GMT</pubDate><dc:creator>sknox</dc:creator></item><item><title>RE: Ghost Cleanup</title><link>http://www.sqlservercentral.com/Forums/Topic1407016-1273-1.aspx</link><description>[quote][b]Sean Lange (1/15/2013)[/b][hr]Great question Wayne. I knew the page would not be deallocated but I didn't know all of the details. The article was very interesting and informative read.I wonder if Celko will start bashing Paul Randal for calling them records instead of rows?? :-D[/quote]:hehe:</description><pubDate>Tue, 15 Jan 2013 08:54:57 GMT</pubDate><dc:creator>SQLRNNR</dc:creator></item><item><title>RE: Ghost Cleanup</title><link>http://www.sqlservercentral.com/Forums/Topic1407016-1273-1.aspx</link><description>Great question Wayne. I knew the page would not be deallocated but I didn't know all of the details. The article was very interesting and informative read.I wonder if Celko will start bashing Paul Randal for calling them records instead of rows?? :-D</description><pubDate>Tue, 15 Jan 2013 08:50:37 GMT</pubDate><dc:creator>Sean Lange</dc:creator></item><item><title>RE: Ghost Cleanup</title><link>http://www.sqlservercentral.com/Forums/Topic1407016-1273-1.aspx</link><description>[quote][b]IgorMi (1/15/2013)[/b][hr]Hi,Interesting question!The expected one data page will be listed after rebuilding the index on the table.alter index  PK_Test on dbo.Test rebuilddbcc ind ('TestDB','Test',1)Thanks,IgorMi[/quote]Absolutely correct (and this was pointed out in the demonstration example on my blog at [url=http://blog.waynesheffield.com/wayne/archive/2012/12/ghost-cleanup-process/][u]http://blog.waynesheffield.com/wayne/archive/2012/12/ghost-cleanup-process/[/u][/url])</description><pubDate>Tue, 15 Jan 2013 08:35:51 GMT</pubDate><dc:creator>WayneS</dc:creator></item><item><title>RE: Ghost Cleanup</title><link>http://www.sqlservercentral.com/Forums/Topic1407016-1273-1.aspx</link><description>Hi,Interesting question!The expected one data page will be listed after rebuilding the index on the table.alter index  PK_Test on dbo.Test rebuilddbcc ind ('TestDB','Test',1)Thanks,IgorMi</description><pubDate>Tue, 15 Jan 2013 08:18:29 GMT</pubDate><dc:creator>IgorMi</dc:creator></item><item><title>RE: Ghost Cleanup</title><link>http://www.sqlservercentral.com/Forums/Topic1407016-1273-1.aspx</link><description>[quote][b]okbangas (1/15/2013)[/b][hr]As far as I understand it, there is something missing from the explanation. If we assume that only what's  written in the scenario has happened, the scenario is as follows:* Table is created* Records are inserted* Records are deleted -&amp;gt; Marked as ghost* Ghost Cleanup Task is running (every 5 seconds).But, there has not been any scan between the marking of ghost records and Ghost Cleanup Task, hence it has nothing to do.[quote]The ghost cleanup task doesn't just start up when it's told to – it starts up in the background every 5 seconds and looks for ghost records to cleanup. Remember that it won't be told to go cleanup a specific page by a delete operation – it's a subsequent scan that does it, if a scan happens.[/quote] [url=http://www.sqlskills.com/blogs/paul/inside-the-storage-engine-ghost-cleanup-in-depth/]http://www.sqlskills.com/blogs/paul/inside-the-storage-engine-ghost-cleanup-in-depth/[/url][/quote]You're absolutely correct. However, the question states:[quote]If you delete the first 12 records, how many data pages will the table have [b][i]after[/i][/b] the Ghost Cleanup process has been run against this table?[/quote] It's not going to run against this table until something scans this table, but once it does, it will leave that page with only one record in it.</description><pubDate>Tue, 15 Jan 2013 08:07:38 GMT</pubDate><dc:creator>WayneS</dc:creator></item><item><title>RE: Ghost Cleanup</title><link>http://www.sqlservercentral.com/Forums/Topic1407016-1273-1.aspx</link><description>[quote][b]okbangas (1/15/2013)[/b][hr]As far as I understand it, there is something missing from the explanation. If we assume that only what's  written in the scenario has happened, the scenario is as follows:* Table is created* Records are inserted* Records are deleted -&amp;gt; Marked as ghost* Ghost Cleanup Task is running (every 5 seconds).But, there has not been any scan between the marking of ghost records and Ghost Cleanup Task, hence it has nothing to do.[/quote]I agree with you that in this scenario the scan was not done, so nothing was done, but that is not relevant for the explanation: the page will [b]never[/b] be completely deleted by the Ghost Cleanup Task, even if it would have been scanned before. As far as I can see that was the important lesson to be learned here.</description><pubDate>Tue, 15 Jan 2013 07:53:06 GMT</pubDate><dc:creator>Mighty</dc:creator></item><item><title>RE: Ghost Cleanup</title><link>http://www.sqlservercentral.com/Forums/Topic1407016-1273-1.aspx</link><description>[quote][b]paul.knibbs (1/15/2013)[/b][hr][quote][b]okbangas (1/15/2013)[/b]But, there has not been any scan between the marking of ghost records and Ghost Cleanup Task, hence it has nothing to do.[/quote]I think that's a scan that's carried out by the ghost cleanup task itself, not a random scan that's done as part of a SELECT statement. May be wrong on that, but that's how I read it![/quote]+1Great question Wayne, thanks.</description><pubDate>Tue, 15 Jan 2013 07:06:58 GMT</pubDate><dc:creator>DugyC</dc:creator></item><item><title>RE: Ghost Cleanup</title><link>http://www.sqlservercentral.com/Forums/Topic1407016-1273-1.aspx</link><description>Good question Wayne.  Thanks!</description><pubDate>Tue, 15 Jan 2013 06:52:42 GMT</pubDate><dc:creator>mtassin</dc:creator></item><item><title>RE: Ghost Cleanup</title><link>http://www.sqlservercentral.com/Forums/Topic1407016-1273-1.aspx</link><description>[quote][b]okbangas (1/15/2013)[/b]But, there has not been any scan between the marking of ghost records and Ghost Cleanup Task, hence it has nothing to do.[/quote]I think that's a scan that's carried out by the ghost cleanup task itself, not a random scan that's done as part of a SELECT statement. May be wrong on that, but that's how I read it!</description><pubDate>Tue, 15 Jan 2013 06:06:36 GMT</pubDate><dc:creator>paul.knibbs</dc:creator></item><item><title>RE: Ghost Cleanup</title><link>http://www.sqlservercentral.com/Forums/Topic1407016-1273-1.aspx</link><description>Good question, thanks WayneHad to dust off the old plates for this one...</description><pubDate>Tue, 15 Jan 2013 05:21:27 GMT</pubDate><dc:creator>Stewart "Arturius" Campbell</dc:creator></item><item><title>RE: Ghost Cleanup</title><link>http://www.sqlservercentral.com/Forums/Topic1407016-1273-1.aspx</link><description>Nice question, thanks.</description><pubDate>Tue, 15 Jan 2013 02:55:42 GMT</pubDate><dc:creator>Gazareth</dc:creator></item><item><title>RE: Ghost Cleanup</title><link>http://www.sqlservercentral.com/Forums/Topic1407016-1273-1.aspx</link><description>Great question. I needed to know. Lost a point but worth the knowledge.</description><pubDate>Tue, 15 Jan 2013 02:45:00 GMT</pubDate><dc:creator>sqlnaive</dc:creator></item><item><title>RE: Ghost Cleanup</title><link>http://www.sqlservercentral.com/Forums/Topic1407016-1273-1.aspx</link><description>Interesting!Thanks!:-)</description><pubDate>Tue, 15 Jan 2013 01:33:44 GMT</pubDate><dc:creator>Carlo Romagnano</dc:creator></item><item><title>RE: Ghost Cleanup</title><link>http://www.sqlservercentral.com/Forums/Topic1407016-1273-1.aspx</link><description>Good question Wayne - thanks</description><pubDate>Tue, 15 Jan 2013 00:49:46 GMT</pubDate><dc:creator>Stuart Davies</dc:creator></item><item><title>RE: Ghost Cleanup</title><link>http://www.sqlservercentral.com/Forums/Topic1407016-1273-1.aspx</link><description>Great question Wayne, thanks. Definately learned something.</description><pubDate>Tue, 15 Jan 2013 00:35:28 GMT</pubDate><dc:creator>Koen Verbeeck</dc:creator></item><item><title>RE: Ghost Cleanup</title><link>http://www.sqlservercentral.com/Forums/Topic1407016-1273-1.aspx</link><description>As far as I understand it, there is something missing from the explanation. If we assume that only what's  written in the scenario has happened, the scenario is as follows:* Table is created* Records are inserted* Records are deleted -&amp;gt; Marked as ghost* Ghost Cleanup Task is running (every 5 seconds).But, there has not been any scan between the marking of ghost records and Ghost Cleanup Task, hence it has nothing to do.[quote]The ghost cleanup task doesn't just start up when it's told to – it starts up in the background every 5 seconds and looks for ghost records to cleanup. Remember that it won't be told to go cleanup a specific page by a delete operation – it's a subsequent scan that does it, if a scan happens.[/quote] [url=http://www.sqlskills.com/blogs/paul/inside-the-storage-engine-ghost-cleanup-in-depth/]http://www.sqlskills.com/blogs/paul/inside-the-storage-engine-ghost-cleanup-in-depth/[/url]</description><pubDate>Tue, 15 Jan 2013 00:10:05 GMT</pubDate><dc:creator>okbangas</dc:creator></item><item><title>RE: Ghost Cleanup</title><link>http://www.sqlservercentral.com/Forums/Topic1407016-1273-1.aspx</link><description>Thanks Wayne</description><pubDate>Mon, 14 Jan 2013 23:13:44 GMT</pubDate><dc:creator>SQLRNNR</dc:creator></item><item><title>RE: Ghost Cleanup</title><link>http://www.sqlservercentral.com/Forums/Topic1407016-1273-1.aspx</link><description>I got it right for wrong reasons ;Learned something.. thanks for the question..</description><pubDate>Mon, 14 Jan 2013 22:18:45 GMT</pubDate><dc:creator>demonfox</dc:creator></item><item><title>RE: Ghost Cleanup</title><link>http://www.sqlservercentral.com/Forums/Topic1407016-1273-1.aspx</link><description>Thanks Wayne. Got to learn something new today :-)</description><pubDate>Mon, 14 Jan 2013 22:04:03 GMT</pubDate><dc:creator>Lokesh Vij</dc:creator></item><item><title>Ghost Cleanup</title><link>http://www.sqlservercentral.com/Forums/Topic1407016-1273-1.aspx</link><description>Comments posted to this topic are about the item [B]&lt;A HREF="/questions/ghost+cleanup/95746/"&gt;Ghost Cleanup&lt;/A&gt;[/B]</description><pubDate>Mon, 14 Jan 2013 21:41:34 GMT</pubDate><dc:creator>WayneS</dc:creator></item></channel></rss>