Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Alter Index : Rebuild Expand / Collapse
Author
Message
Posted Monday, December 17, 2012 2:14 AM


SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Tuesday, August 19, 2014 12:26 AM
Points: 2,840, Visits: 3,963
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
Post #1397147
Posted Monday, December 17, 2012 5:47 AM
SSC Eights!

SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!

Group: General Forum Members
Last Login: Wednesday, September 10, 2014 6:34 AM
Points: 870, Visits: 2,388
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
Post #1397210
Posted Monday, December 17, 2012 11:39 PM


SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Tuesday, August 19, 2014 12:26 AM
Points: 2,840, Visits: 3,963
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
Post #1397570
Posted Tuesday, December 18, 2012 4:39 AM
SSC Eights!

SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!

Group: General Forum Members
Last Login: Wednesday, September 10, 2014 6:34 AM
Points: 870, Visits: 2,388
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
Post #1397695
Posted Tuesday, December 18, 2012 4:42 AM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Today @ 2:20 AM
Points: 5,231, Visits: 5,106
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
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

Post #1397696
Posted Tuesday, December 18, 2012 4:56 AM


SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Tuesday, August 19, 2014 12:26 AM
Points: 2,840, Visits: 3,963
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
Post #1397698
Posted Tuesday, December 18, 2012 5:01 AM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Today @ 2:20 AM
Points: 5,231, Visits: 5,106
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
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

Post #1397703
Posted Tuesday, December 18, 2012 6:17 AM
SSC Eights!

SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!

Group: General Forum Members
Last Login: Wednesday, September 10, 2014 6:34 AM
Points: 870, Visits: 2,388
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
Post #1397744
Posted Tuesday, December 18, 2012 6:31 AM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Today @ 2:20 AM
Points: 5,231, Visits: 5,106
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
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

Post #1397756
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse