home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   comp.databases.ms-sqlserver      Notorious Rube Goldberg contraption      19,505 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 18,875 of 19,505   
   Erland Sommarskog to rja.carnegie@gmail.com   
   Re: Some questions about relational inde   
   07 May 13 21:26:41   
   
   From: esquel@sommarskog.se   
      
    (rja.carnegie@gmail.com) writes:   
   > 1. A nonclustered index can "include" columns that are not part of   
   >    the index key: can this be done with a nonclustered primary key   
   >    constraint index?   
      
   No.   
      
   > but the workaround might be to /not/ have a primary key,   
   > but have a unique nonclustered index with included columns, which   
   > does everything except display that it is the table's primary key,   
      
   You could, but I have never seen the need. But, yeah, I could see the   
   scenario.   
      
   > /or/, to create and then /disable/ the primary key index (if you   
   > can do that), /and/ create the unique nonclustered index.   
      
   You can't disable the PK.   
      
   > 2. Will SQL Server ever automatically create a separate statistics group   
   >    on columns that are already the key of a clustered or nonclustered   
   >    index?  And, if so, should I consider improving the index so that   
   >    it provides a satisfactory statistics group, and, how can I do that?   
      
   Not sure that I understand the question, but SQL Server always creates   
   statistics on the index columns. I have never heard "statistics group"   
   before, but maybe you mean multi-column statistics.   
      
   > (1) an index was created later than when the table was created, and a   
   > statistics group was already auto-created on the columns before the   
   > index was;   
      
   Auto-stats are always single column statistics. Multi-column statistics   
   are always user-initiated, either through CREATE INDEX or CREATE   
   STATISTICS.   
      
   > (3) an index and a statistics group are on more than one column   
   > and have some of the same columns, or have columns in a different order;   
      
   Then they are different indexes and statistics. Orders matter in   
   both.   
      
   > (4) a user-created statistics group has the same columns as an index.   
   > Maybe all at the same time.  All I know now is, they're there,   
   > and I think they're a bad sign.   
      
   If there is a user-defined statistics which has the same definition as   
   an index, that statistics is redundant and should be dropped.   
      
      
   --   
   Erland Sommarskog, Stockholm, esquel@sommarskog.se   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca