Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase «««123

primary key discussion Expand / Collapse
Author
Message
Posted Friday, August 29, 2014 1:03 PM


SSC-Insane

SSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-Insane

Group: General Forum Members
Last Login: Today @ 10:59 AM
Points: 21,768, Visits: 34,442
ScottPletcher (8/29/2014)
The page split / fragmentation concern is often overblown. Remember, one INSERT, but you may read the row 1000, 10K, 100K+(?) or more times. Particularly given the availability of partitions, reorganizations, online rebuilds, etc., some fragmentation can be dealt with far better than using the wrong clus key just to reduce frag on the single INSERT of each row while drastically harming the performance of the vast majority of future SELECTs.


Until you find yourself in that position. I haven't but I have talked with someone who was in that exact environment and defragging a highly fragmented clustered index would basically shutdown the mirroring to the DR site which is over a slow WAN connection.

You have to work with what you have and make the systems work under less than optimum conditions.



Lynn Pettis

For better assistance in answering your questions, click here
For tips to get better help with Performance Problems, click here
For Running Totals and its variations, click here or when working with partitioned tables
For more about Tally Tables, click here
For more about Cross Tabs and Pivots, click here and here
Managing Transaction Logs

SQL Musings from the Desert Fountain Valley SQL (My Mirror Blog)
Post #1608725
Posted Friday, August 29, 2014 1:11 PM
SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Today @ 11:13 AM
Points: 2,881, Visits: 4,377
Lynn Pettis (8/29/2014)
ScottPletcher (8/29/2014)
The page split / fragmentation concern is often overblown. Remember, one INSERT, but you may read the row 1000, 10K, 100K+(?) or more times. Particularly given the availability of partitions, reorganizations, online rebuilds, etc., some fragmentation can be dealt with far better than using the wrong clus key just to reduce frag on the single INSERT of each row while drastically harming the performance of the vast majority of future SELECTs.


Until you find yourself in that position. I haven't but I have talked with someone who was in that exact environment and defragging a highly fragmented clustered index would basically shutdown the mirroring to the DR site which is over a slow WAN connection.

You have to work with what you have and make the systems work under less than optimum conditions.


How did it get "highly" fragmented? For a very large table, that would take a very large number of "bad" (mid-page) page splits, which would not occur with a reasonable clustering key, even if it wasn't universally ascending.


SQL DBA,SQL Server MVP('07, '08, '09)

Carl Sagan said: "There is no such thing as a dumb question." Sagan obviously never watched a congressional hearing!
Post #1608726
Posted Friday, August 29, 2014 1:15 PM
SSCarpal Tunnel

SSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal Tunnel

Group: General Forum Members
Last Login: Today @ 11:06 AM
Points: 4,029, Visits: 10,399
Thank you Scott, Tom and Lynn, this was the discussion I wanted to get going in this context. The subject is far to dependent on the environment and the nature of the dominant activities for one to generalise.
Post #1608729
Posted Friday, August 29, 2014 1:23 PM
SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Today @ 11:13 AM
Points: 2,881, Visits: 4,377
Eirikur Eiriksson (8/29/2014)
Thank you Scott, Tom and Lynn, this was the discussion I wanted to get going in this context. The subject is far to dependent on the environment and the nature of the dominant activities for one to generalise.


Exactly correct! Don't let some nursery-rhyme like saying -- "narrow, unique, ever-ascending" -- bulldoze you into a cluster key selection: do some real analysis, and decide on the best key for your specific situation. The clus key is the single most important factor for performance (in most cases), so don't assume one simple general rule fits your exact situation.


SQL DBA,SQL Server MVP('07, '08, '09)

Carl Sagan said: "There is no such thing as a dumb question." Sagan obviously never watched a congressional hearing!
Post #1608732
Posted Friday, August 29, 2014 1:42 PM


SSC-Insane

SSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-Insane

Group: General Forum Members
Last Login: Today @ 10:59 AM
Points: 21,768, Visits: 34,442
ScottPletcher (8/29/2014)
Lynn Pettis (8/29/2014)
ScottPletcher (8/29/2014)
The page split / fragmentation concern is often overblown. Remember, one INSERT, but you may read the row 1000, 10K, 100K+(?) or more times. Particularly given the availability of partitions, reorganizations, online rebuilds, etc., some fragmentation can be dealt with far better than using the wrong clus key just to reduce frag on the single INSERT of each row while drastically harming the performance of the vast majority of future SELECTs.


Until you find yourself in that position. I haven't but I have talked with someone who was in that exact environment and defragging a highly fragmented clustered index would basically shutdown the mirroring to the DR site which is over a slow WAN connection.

You have to work with what you have and make the systems work under less than optimum conditions.


How did it get "highly" fragmented? For a very large table, that would take a very large number of "bad" (mid-page) page splits, which would not occur with a reasonable clustering key, even if it wasn't universally ascending.


Never asked for the details. What made sense as a clustered index for data access would fragment the index rapidly affecting system performance. Defragging the index would essentially shutdown the mirroring to the DR site.

The choice of a clustering index is more than data access it is also dependent on the environment. In this case a very narrow ever increasing clustered index was the best choice as it kept the index from fragmenting.




Lynn Pettis

For better assistance in answering your questions, click here
For tips to get better help with Performance Problems, click here
For Running Totals and its variations, click here or when working with partitioned tables
For more about Tally Tables, click here
For more about Cross Tabs and Pivots, click here and here
Managing Transaction Logs

SQL Musings from the Desert Fountain Valley SQL (My Mirror Blog)
Post #1608739
Posted Friday, August 29, 2014 5:34 PM


SSCrazy Eights

SSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy Eights

Group: General Forum Members
Last Login: Today @ 4:19 AM
Points: 8,570, Visits: 10,340
CELKO (8/29/2014)
How about something like Coupon types? What would you use there? I am certainly not going to use the description of the type (PercentageDiscount, FreeShipping, BOGO, etc).


A type is an attribute, measured on an enumeration scale. It is not an identifier, so it cannot be key.

It seems to me reasonable to interpret Sean as referring to a column whose domain is a Coupon Descriptions (or Coupon Type Names if you would rather call them that) and it seems to me to require a considerable degree of unreasonableness to interpret him differently.
I know that the SQL standard doesn't include such domains, but it is easy enough to define such a domain using a varchar type and a check constraint, or alternatively with an auxiliary table enumerating the values and having an interger (or tinyint, smallint, or bigint) surrogate key with the domain being represented in other tables by an integer column with a foreign key reference to the auxiliary table.


Tom
Post #1608781
« Prev Topic | Next Topic »

Add to briefcase «««123

Permissions Expand / Collapse