none
Statistis update report showing null values SQL SERVER 12 SP3 RRS feed

  • Question

  • I ran the query below which gives me statistics report about when it was last updated but for some reason some of the them returned null value.

    Please can any one explain to me the reason for the null values?

    Can this affect performance in any way? if yes

    Please suggest resolution

    Thanks

    SELECT

    DISTINCT


    OBJECT_NAME

    (s.[object_id])ASTableName,


    c

    .name ASColumnName,


    s

    .name ASStatName,


    STATS_DATE

    (s.[object_id],s.stats_id)ASLastUpdated,


    DATEDIFF

    (d,STATS_DATE(s.[object_id],s.stats_id),getdate())DaysOld,


    dsp

    .modification_counter,


    s

    .auto_created,


    s

    .user_created,


    s

    .no_recompute,


    s

    .[object_id],


    s

    .stats_id,


    sc

    .stats_column_id,


    sc

    .column_id


    FROM

    sys.statss


    JOIN

    sys.stats_columnssc


    ON

    sc.[object_id] =s.[object_id] ANDsc.stats_id =s.stats_id


    JOIN

    sys.columnsc ONc.[object_id] =sc.[object_id] ANDc.column_id =sc.column_id


    JOIN

    sys.partitionspar ONpar.[object_id] =s.[object_id]


    JOIN

    sys.objectsobj ONpar.[object_id] =obj.[object_id]


    CROSS

    APPLYsys.dm_db_stats_properties(sc.[object_id],s.stats_id)ASdsp


    WHERE

    OBJECTPROPERTY(s.OBJECT_ID,'IsUserTable')=1


    AND

    (s.auto_created =1 ORs.user_created =1)


    ORDER

    BYDaysOld;

    Tuesday, June 25, 2019 8:55 PM

All replies

  • The NULL value would indicate that the statistics have never been updated.

    In the posting UI, there is a button with two arrows pointing from each other. You can use this post to insert code samples, without the posting UI mangling the code.


    Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se

    Tuesday, June 25, 2019 9:50 PM
    Moderator
  • Thanks for that information.

    I would assume this can degrade performance right ?

    Wednesday, June 26, 2019 2:01 PM