Home Forums SQL Server 2012 SQL 2012 - General SQL Server 2012, update Stats and Index Organize taking 16 hours for execution‌‌ RE: SQL Server 2012, update Stats and Index Organize taking 16 hours for execution??

  • santosh.mane - Thursday, February 22, 2018 7:50 AM

    andrew gothard - Tuesday, February 20, 2018 3:14 AM

    Hi.
    One thing I would look for is whether any of the legacy LoB datatypes are used in any of the tables, text, ntext and image.  I have seen a number of cases where their use, especially on large tables, causes this type of problem, particularly with stats updates.
    Try running this;

    SELECT

    Schemas.name + '.' + Tables.name TableName, Columns.Name ColumnName, Types.Name DataType

    FROM

    sys.schemas Schemas

    INNER JOIN

    sys.tables Tables

    ON Schemas.schema_id = Tables.schema_id

    INNER JOIN

    sys.stats Stats

    ON Tables.object_id = Stats.object_id

    INNER JOIN

    sys.stats_columns StatsColumns

    ON Stats.object_id = StatsColumns.object_id AND

    Stats.stats_id = StatsColumns.stats_id

    INNER JOIN

    sys.columns Columns

    ON StatsColumns.object_id = Columns.object_id AND

    StatsColumns.column_id = Columns.column_id

    INNER JOIN

    sys.types AS Types

    ON Columns.system_type_id = Types.system_type_id

    WHERE

    Types.name IN ('image', 'ntext', 'text')

    If so, if you can get back with your results, that'd be helpful

    No there are no objects with image or ntext or text.

    Thanks for getting back.
    Well, that wasn't what I was expecting. 
    What maintenance tools are you using?  First off, can you see if it's the re-indexing or the stats update that's taking longest.  If your maintenance tool logs activity (and if it doesn't, I would personally swap it for something that does otherwise troubleshooting consists mostly of guessing) on an object by object basis, can you see which object or objects are taking a disproportionate length of time?

    I'm a DBA.
    I'm not paid to solve problems. I'm paid to prevent them.