SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Alter Index : Rebuild


Alter Index : Rebuild

Author
Message
Bhuvnesh
Bhuvnesh
SSCertifiable
SSCertifiable (6.9K reputation)SSCertifiable (6.9K reputation)SSCertifiable (6.9K reputation)SSCertifiable (6.9K reputation)SSCertifiable (6.9K reputation)SSCertifiable (6.9K reputation)SSCertifiable (6.9K reputation)SSCertifiable (6.9K reputation)

Group: General Forum Members
Points: 6850 Visits: 4076
HI

i have rebuilt one of the clustered index , table definition
CREATE TABLE [Person].[Person_BK](
[BusinessEntityID] [int] identity NOT NULL,
[PersonType] [nchar](10) NOT NULL,
[NameStyle] [dbo].[NameStyle] NOT NULL,
[Title] [nvarchar](30) NULL,
[Name] [nvarchar](3000) NULL,
[Suffix] [nvarchar](10) NULL,
[EmailPromotion] [int] NOT NULL,
[AdditionalContactInfo] [xml] NULL,
[Demographics] [xml] NULL,
[rowguid] [uniqueidentifier] ROWGUIDCOL NOT NULL,
[ModifiedDate] [datetime] NOT NULL,
CONSTRAINT [PK_Person_BusinessEntityID_bk] PRIMARY KEY CLUSTERED
(
[BusinessEntityID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO




query
select * from  sys.dm_db_index_physical_stats(11, OBJECT_ID('[Person].[Person_BK]'),NULL, NULL, NULL)



before UPDATE stmt :


index_id partition_number index_type_desc alloc_unit_type_desc index_depth index_level
1 1 CLUSTERED INDEX IN_ROW_DATA 4 0
avg_fragmentation_in_percent
5.04512377527183


Atfer UPDATE stmt :


11 861246123 1 1 CLUSTERED INDEX IN_ROW_DATA 3 0 0.01
11 861246123 1 1 CLUSTERED INDEX ROW_OVERFLOW_DATA 1 0 0
11 861246123 1 1 CLUSTERED INDEX LOB_DATA 1 0 0


Can anybody tell me why i am getting 3 records after UPDATE query

Queries are


update [Person].[Person_BK]

set [Title] = 'MRnd'
WHERE [BusinessEntityID] like '%090%'



update [Person].[Person_BK]

set [Title] = 'ffg',
[Name] = 'sdgsdgs'
WHERE [BusinessEntityID] like '%67%'



update [Person].[Person_BK]

set [Title] = 'ffg',
[Name] = 'gsdgsdg'
WHERE [BusinessEntityID] like '%40%'



update [Person].[Person_BK]

set [Title] = 'ffg',
[Name] = 'hdfhfdh'
WHERE [BusinessEntityID] like '%90%'



update [Person].[Person_BK]

set [Title] = 'ffg',
[Name] = 'safsfsd'
WHERE [BusinessEntityID] like '%09%'


update [Person].[Person_BK]

set [Title] = 'ffg',
[Name] = 'gdghfdhd'
WHERE [BusinessEntityID] like '%45%'







-------Bhuvnesh----------
I work only to learn Sql Server...though my company pays me for getting their stuff done;-)
Jason-299789
Jason-299789
SSCrazy
SSCrazy (2.6K reputation)SSCrazy (2.6K reputation)SSCrazy (2.6K reputation)SSCrazy (2.6K reputation)SSCrazy (2.6K reputation)SSCrazy (2.6K reputation)SSCrazy (2.6K reputation)SSCrazy (2.6K reputation)

Group: General Forum Members
Points: 2619 Visits: 3232
By any chance did you update one or more of the XML columns, as these (from memory) are stored as LOB's so pointers would be created to them hence the extra 2.

_________________________________________________________________________
SSC Guide to Posting and Best Practices
Bhuvnesh
Bhuvnesh
SSCertifiable
SSCertifiable (6.9K reputation)SSCertifiable (6.9K reputation)SSCertifiable (6.9K reputation)SSCertifiable (6.9K reputation)SSCertifiable (6.9K reputation)SSCertifiable (6.9K reputation)SSCertifiable (6.9K reputation)SSCertifiable (6.9K reputation)

Group: General Forum Members
Points: 6850 Visits: 4076
Jason-299789 (12/17/2012)
By any chance did you update one or more of the XML columns, as these (from memory) are stored as LOB's so pointers would be created to them hence the extra 2.
i am only updating [Title] and [Name] columns .

When i do index rebuild
ALTER INDEX [PK_Person_BusinessEntityID_bk] ON [Person].[Person_BK]
REBUILD;

after that sys.dm_db_physical_stats returns 3 rows for this PK. And yes i have 2 XML column in my table (see above table definition ) but NO update on these columns

-------Bhuvnesh----------
I work only to learn Sql Server...though my company pays me for getting their stuff done;-)
Jason-299789
Jason-299789
SSCrazy
SSCrazy (2.6K reputation)SSCrazy (2.6K reputation)SSCrazy (2.6K reputation)SSCrazy (2.6K reputation)SSCrazy (2.6K reputation)SSCrazy (2.6K reputation)SSCrazy (2.6K reputation)SSCrazy (2.6K reputation)

Group: General Forum Members
Points: 2619 Visits: 3232
I have no Idea why a rebuild would do this, as I would have thought the addtionaltwo entries for the the IN_ROW and LOB data would be there as soon as you populate the table.

_________________________________________________________________________
SSC Guide to Posting and Best Practices
anthony.green
anthony.green
SSChampion
SSChampion (12K reputation)SSChampion (12K reputation)SSChampion (12K reputation)SSChampion (12K reputation)SSChampion (12K reputation)SSChampion (12K reputation)SSChampion (12K reputation)SSChampion (12K reputation)

Group: General Forum Members
Points: 12686 Visits: 6519
Unless the de-frag has resulted in ordering which has pushed the lob and row overflow to their correct places in the index.

What is the result of MAX(LEN(column)) for all the columns within the table, and what is the datatype NameStyle?



Want an answer fast? Try here
How to post data/code for the best help - Jeff Moden
When a question, really isn't a question - Jeff Smith
Need a string splitter, try this - Jeff Moden
How to post performance problems - Gail Shaw
CrossTabs-Part1 & Part2 - Jeff Moden
SQL Server Backup, Integrity Check, and Index and Statistics Maintenance - Ola Hallengren
Managing Transaction Logs - Gail Shaw
Troubleshooting SQL Server: A Guide for the Accidental DBA - Jonathan Kehayias and Ted Krueger


Bhuvnesh
Bhuvnesh
SSCertifiable
SSCertifiable (6.9K reputation)SSCertifiable (6.9K reputation)SSCertifiable (6.9K reputation)SSCertifiable (6.9K reputation)SSCertifiable (6.9K reputation)SSCertifiable (6.9K reputation)SSCertifiable (6.9K reputation)SSCertifiable (6.9K reputation)

Group: General Forum Members
Points: 6850 Visits: 4076
anthony.green (12/18/2012)
What is the result of MAX(LEN(column)) for all the columns within the table
from nvarchar(10) to nvarchar(300) plus XML.

anthony.green (12/18/2012)
what is the datatype NameStyle?
nvarchar(30)

-------Bhuvnesh----------
I work only to learn Sql Server...though my company pays me for getting their stuff done;-)
anthony.green
anthony.green
SSChampion
SSChampion (12K reputation)SSChampion (12K reputation)SSChampion (12K reputation)SSChampion (12K reputation)SSChampion (12K reputation)SSChampion (12K reputation)SSChampion (12K reputation)SSChampion (12K reputation)

Group: General Forum Members
Points: 12686 Visits: 6519
Strange on seeing the row_overflow as that should kick in when the row spans more than 8060 bytes, but the maximum row length is only 6148 bytes so strange on that one.

The lob data is expected as it will have farmed the XML columns off to the LOB store tree so will need to be able to use the pointers back to the clustered index.



Want an answer fast? Try here
How to post data/code for the best help - Jeff Moden
When a question, really isn't a question - Jeff Smith
Need a string splitter, try this - Jeff Moden
How to post performance problems - Gail Shaw
CrossTabs-Part1 & Part2 - Jeff Moden
SQL Server Backup, Integrity Check, and Index and Statistics Maintenance - Ola Hallengren
Managing Transaction Logs - Gail Shaw
Troubleshooting SQL Server: A Guide for the Accidental DBA - Jonathan Kehayias and Ted Krueger


Jason-299789
Jason-299789
SSCrazy
SSCrazy (2.6K reputation)SSCrazy (2.6K reputation)SSCrazy (2.6K reputation)SSCrazy (2.6K reputation)SSCrazy (2.6K reputation)SSCrazy (2.6K reputation)SSCrazy (2.6K reputation)SSCrazy (2.6K reputation)

Group: General Forum Members
Points: 2619 Visits: 3232
anthony.green (12/18/2012)
Strange on seeing the row_overflow as that should kick in when the row spans more than 8060 bytes, but the maximum row length is only 6148 bytes so strange on that one.

The lob data is expected as it will have farmed the XML columns off to the LOB store tree so will need to be able to use the pointers back to the clustered index.



Could the Page fill factor be an issue here? where by the Rebuild has used a lower fill factor than when the table was originally built? though in the Alter Index I cant see anything that suggests this is the case.

_________________________________________________________________________
SSC Guide to Posting and Best Practices
anthony.green
anthony.green
SSChampion
SSChampion (12K reputation)SSChampion (12K reputation)SSChampion (12K reputation)SSChampion (12K reputation)SSChampion (12K reputation)SSChampion (12K reputation)SSChampion (12K reputation)SSChampion (12K reputation)

Group: General Forum Members
Points: 12686 Visits: 6519
Potentially down to page splits where the updates have now pushed the xml off into the LOB pages from in_row, depending on how big the XML data is in the column.



Want an answer fast? Try here
How to post data/code for the best help - Jeff Moden
When a question, really isn't a question - Jeff Smith
Need a string splitter, try this - Jeff Moden
How to post performance problems - Gail Shaw
CrossTabs-Part1 & Part2 - Jeff Moden
SQL Server Backup, Integrity Check, and Index and Statistics Maintenance - Ola Hallengren
Managing Transaction Logs - Gail Shaw
Troubleshooting SQL Server: A Guide for the Accidental DBA - Jonathan Kehayias and Ted Krueger


Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search