Thursday, March 8, 2012

ALTER INDEX REORGANIZE vs DBCC INDEXDEFRAG

Is ALTER INDEX REORGANIZE equivalent to DBCC INDEXDEFRAG? In
http://msdn2.microsoft.com/en-us/library/ms189858.aspx it says "
Reorganizing a specified clustered index will compact all LOB columns that
are contained in the leaf level (data rows) of the clustered index" .
According to Kalen Delaney's Inside SQL Server 2005 The Storage Engine p 324
" In SQL Server 2000, the only way you can compact LOBs in a table is to
unload and reload the LOB data"
This would make ALTER INDEX REORGANIZE not equivalent but superior to DBCC
INDEXDEFRAG since it can compact LOB columns whereas DBCC INDEXDEFRAG cannot
.
Is this correct?Mladen Andrijasevic wrote:
> Is ALTER INDEX REORGANIZE equivalent to DBCC INDEXDEFRAG? In
> http://msdn2.microsoft.com/en-us/library/ms189858.aspx it says "
> Reorganizing a specified clustered index will compact all LOB columns that
> are contained in the leaf level (data rows) of the clustered index" .
> According to Kalen Delaney's Inside SQL Server 2005 The Storage Engine p 3
24
> " In SQL Server 2000, the only way you can compact LOBs in a table is to
> unload and reload the LOB data"
> This would make ALTER INDEX REORGANIZE not equivalent but superior to DBC
C
> INDEXDEFRAG since it can compact LOB columns whereas DBCC INDEXDEFRAG cann
ot.
> Is this correct?
from BOL:
ALTER INDEX
...
...
WITH ( LOB_COMPACTION = { ON | OFF } )
Specifies that all pages that contain large object (LOB) data are
compacted. The LOB data types are image, text, ntext, varchar(max),
nvarchar(max), varbinary(max), and xml. Compacting this data can improve
disk space use. The default is ON.|||Hi, according BOL (Jul 2007), ALTER INDEX ... REORGANIZE is Equivalent to
DBCC INDEXDEFRAG. is the same.
Regards,
"Mladen Andrijasevic" wrote:

> Is ALTER INDEX REORGANIZE equivalent to DBCC INDEXDEFRAG? In
> http://msdn2.microsoft.com/en-us/library/ms189858.aspx it says "
> Reorganizing a specified clustered index will compact all LOB columns that
> are contained in the leaf level (data rows) of the clustered index" .
> According to Kalen Delaney's Inside SQL Server 2005 The Storage Engine p 3
24
> " In SQL Server 2000, the only way you can compact LOBs in a table is to
> unload and reload the LOB data"
> This would make ALTER INDEX REORGANIZE not equivalent but superior to DBC
C
> INDEXDEFRAG since it can compact LOB columns whereas DBCC INDEXDEFRAG cann
ot.
> Is this correct?|||I believe the following white has the info you need. It covers SQL2000, but
most materials should still be relevant.
http://www.microsoft.com/technet/pr...n/ss2kidbp.mspx
Linchi
"Mladen Andrijasevic" wrote:

> Is ALTER INDEX REORGANIZE equivalent to DBCC INDEXDEFRAG? In
> http://msdn2.microsoft.com/en-us/library/ms189858.aspx it says "
> Reorganizing a specified clustered index will compact all LOB columns that
> are contained in the leaf level (data rows) of the clustered index" .
> According to Kalen Delaney's Inside SQL Server 2005 The Storage Engine p 3
24
> " In SQL Server 2000, the only way you can compact LOBs in a table is to
> unload and reload the LOB data"
> This would make ALTER INDEX REORGANIZE not equivalent but superior to DBC
C
> INDEXDEFRAG since it can compact LOB columns whereas DBCC INDEXDEFRAG cann
ot.
> Is this correct?|||Zarko,
I am aware that LOB_COMPACTION default is ON . It was the point of my
question. From this it would fiollow that saying that "ALTER INDEX ...
REORGANIZE is Equivalent to DBCC INDEXDEFRAG " is wrong . But I have not com
e
across a statement saying so , or saying that ALTER INDEX ... REORGANIZE
should be immediately implemented on sql 2005 instead of DBCC INDEXDEFRAG
because it does more than DBCC INDEXDEFRAG , i.e. it can compact LOBs
Thanks
Mladen
"Zarko Jovanovic" wrote:

> Mladen Andrijasevic wrote:
> from BOL:
> ALTER INDEX
> ...
> ...
> WITH ( LOB_COMPACTION = { ON | OFF } )
> Specifies that all pages that contain large object (LOB) data are
> compacted. The LOB data types are image, text, ntext, varchar(max),
> nvarchar(max), varbinary(max), and xml. Compacting this data can improve
> disk space use. The default is ON.
>|||Carlos ,
Well, the purpose of my question was precisely to clarify how to reconcile
what is written in BOL in one place , i.e. that ALTER INDEX ...
REORGANIZE is Equivalent to DBCC INDEXDEFRAG, with what is written in
another place in SQL Server 2005 Books Online (September 2007) i.e. that
ALTER INDEX ... REORGANIZE can compact LOBs . They cannot be equivalent i
f
ALTER INDEX ... REORGANIZE does more than DBCC INDEXDEFRAG!
Thanks
Mladen
"Carlos A." wrote:
[vbcol=seagreen]
> Hi, according BOL (Jul 2007), ALTER INDEX ... REORGANIZE is Equivalent to
> DBCC INDEXDEFRAG. is the same.
> Regards,
>
> "Mladen Andrijasevic" wrote:
>|||Linchi,
I 've read Microsoft SQL Server 2000 Index Defragmentation Best Practices
and implemented its recommendations a few years ago . However, it cannot
provide an answer to my question since my question has todo with the
comparsion of DBCC INDEXDEFRAG of sql 2000 . to ALTER INDEX ... REORGANIZE o
f
sql 2005, which is not mentioned in the Server 2000 Index Defragmentation
Best Practices document since it appeared only in SQL 2005
Thanks
Mladen
"Linchi Shea" wrote:
[vbcol=seagreen]
> I believe the following white has the info you need. It covers SQL2000, bu
t
> most materials should still be relevant.
> [url]http://www.microsoft.com/technet/prodtechnol/sql/2000/maintain/ss2kidbp.mspx[/ur
l]
> Linchi
> "Mladen Andrijasevic" wrote:
>|||> Well, the purpose of my question was precisely to clarify how to
> reconcile
> what is written in BOL in one place , i.e. that ALTER INDEX ...
> REORGANIZE is Equivalent to DBCC INDEXDEFRAG, with what is written in
> another place in SQL Server 2005 Books Online (September 2007) i.e. that
> ALTER INDEX ... REORGANIZE can compact LOBs . They cannot be equivalent
> if
> ALTER INDEX ... REORGANIZE does more than DBCC INDEXDEFRAG!
I think using the default behavior they are equivalent. Just because one
has some different *optional* commands does not make them completely
different animals.
Would you say that CAST and CONVERT are "equivalent"? How about ISNULL()
and COALESCE()?
In any case, I do agree that perhaps the wording could be a little less
ambiguous. Maybe you should click on the feedback item on that page in
Books Online, and voice your concerns? That feedback will make its way
directly to the writer of the topic.
A|||Aaron ,
I am not such a stickler over the wording at all. I just need to find out
whether it makes sense to implement ALTER INDEX . REORGANIZE over DBCC
INDEXDEFRAG on our SQL 2005 systems. If they were equivalent I would not
bother to do it right away . So would you say that ALTER INDEX . REORGANIZ
E
would better defrgarment than DBCC INDEXDEFRAG since ALTER INDEX .
REORGANIZE would compact LOBs and DBCC INDEXDEFRAG would not?
Thanks
Mladen
"Aaron Bertrand [SQL Server MVP]" wrote:

> I think using the default behavior they are equivalent. Just because one
> has some different *optional* commands does not make them completely
> different animals.
> Would you say that CAST and CONVERT are "equivalent"? How about ISNULL()
> and COALESCE()?
> In any case, I do agree that perhaps the wording could be a little less
> ambiguous. Maybe you should click on the feedback item on that page in
> Books Online, and voice your concerns? That feedback will make its way
> directly to the writer of the topic.
> A
>
>|||Aaron,
Just noticed the " I think using the default behavior they are equivalent"
I do not think this is true either since LOB_COMPACTION = ON is the default
and that is precisely where they differ!
Mladen
"Aaron Bertrand [SQL Server MVP]" wrote:

> I think using the default behavior they are equivalent. Just because one
> has some different *optional* commands does not make them completely
> different animals.
> Would you say that CAST and CONVERT are "equivalent"? How about ISNULL()
> and COALESCE()?
> In any case, I do agree that perhaps the wording could be a little less
> ambiguous. Maybe you should click on the feedback item on that page in
> Books Online, and voice your concerns? That feedback will make its way
> directly to the writer of the topic.
> A
>
>

No comments:

Post a Comment