Empty pages in a heap don't always get deallocated when they become empty.
Only when LCK_M_X table lock is held when the page is changed to empty, the
page is deallocated. There are design reasons behind this in order for the
concurrent scan to work, which I am going to go in detail here.
In conclusion, if the heap used to contain a lot of rows and most of the
rows were deleted subsequently without a X table lock, it will end up with
lots of empty pages. In that case, build a clustered index(plus dropping
the index later if you really want just a heap) on it will deallocate those
empty pages.
--
Gang He
Software Design Engineer
Microsoft SQL Server Storage Engine
This posting is provided "AS IS" with no warranties, and confers no rights.
"Jakob" <ja*************@hotmail.com> wrote in message
news:41*********************@dread11.news.tele.dk. ..
Hello,
I have experienced that some of my tables occupies an extremely large
amount of pages but with few rows. An example is a table with 37 rows over 22000
pages !. The columns are simple integer and char. I fixed the problem by
introducing a clustered index. Now it only uses 1 page. But can anyone
explain this behaviour in SQLServer 2000 ?
regards Jakob Mathiasen