문제

I had always understood that SQL Server auto-created statistics only include one column. In other words, they are not multi-column statistics.

However, today I came across some auto-created statistics that have two columns. The second column is always the primary key of the table. There are other auto-created statistics on the same table that don't have a second column.

enter image description here

auto_created = 1 on the sys.stats table.

Also, some statistics have a different naming convention on the exact same tables. Some of them have a column name in the statistic name. What makes SQL use a different naming convention? For example,

  • _WA_Sys_BegEffDate_7363C5E4
  • _WA_Sys_0000000B_7363C5E4

These are not causing problems, I am just curious about it.

도움이 되었습니까?

해결책

I have spent a decent amount of time searching for an explanation of the different naming conventions on some of my own databases, and haven't found anything definitive.

That being said, in both our cases we are dealing with very old databases that have undergone many upgrades over the years. My best guess is that at some point Microsoft switched the auto-created statistics to use an incremental alphanumeric pattern instead of using partial column names (somewhere around SQL Server 2000 or 2005?). This may have been done to reduce the potential for naming conflicts or to better handle the renaming of a column.

I haven't seen the Primary Key be added into auto-created statistics, but that might also be an artifact of a very old version.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 dba.stackexchange
scroll top