Alter Index : Rebuild

  • 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_idpartition_numberindex_type_desc alloc_unit_type_descindex_depthindex_level

    1 1 CLUSTERED INDEX IN_ROW_DATA 4 0

    avg_fragmentation_in_percent

    5.04512377527183

    Atfer UPDATE stmt :

    1186124612311CLUSTERED INDEXIN_ROW_DATA300.01

    1186124612311CLUSTERED INDEXROW_OVERFLOW_DATA100

    1186124612311CLUSTERED INDEXLOB_DATA100

    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;-)

  • 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

  • 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;-)

  • 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

  • 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?

  • 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;-)

  • 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.

  • 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

  • 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.

Viewing 9 posts - 1 through 8 (of 8 total)

You must be logged in to reply to this topic. Login to reply