October 3, 2008 at 12:48 pm
Essentially, I'm curious if the position of an FK column matters for performance.
That is, is:
CREATE TABLE User (
UserId INT IDENTITY(1,1) PRIMARY KEY,
UserTypeId INT REFERENCES UserType(UserTypeId),
-- 50 columns
);
any faster to select the UserTypes from than
CREATE TABLE User (
UserId INT IDENTITY(1,1) PRIMARY KEY,
-- 50 columns
UserTypeId INT REFERENCES UserType(UserTypeId)
);
Jeremiah Peschka
Microsoft SQL Server MVP
Managing Director - Brent Ozar PLF, LLC
October 3, 2008 at 12:59 pm
jeremiah.peschka (10/3/2008)
Essentially, I'm curious if the position of an FK column matters for performance.That is, is:
CREATE TABLE User (
UserId INT IDENTITY(1,1) PRIMARY KEY,
UserTypeId INT REFERENCES UserType(UserTypeId),
-- 50 columns
);
any faster to select the UserTypes from than
CREATE TABLE User (
UserId INT IDENTITY(1,1) PRIMARY KEY,
-- 50 columns
UserTypeId INT REFERENCES UserType(UserTypeId)
);
The location of the foreign key column in the create table statement has nothing to do with performance. By the way, the physical order of the columns on the disk is not necessarily the same as the logical order of the columns.
--------------------------------------------------------------
To know how to ask questions and increase the chances of getting asnwers:
http://www.sqlservercentral.com/articles/Best+Practices/61537/
For better answers on performance questions, click on the following...
http://www.sqlservercentral.com/articles/SQLServerCentral/66909/
October 3, 2008 at 1:02 pm
No. The declared order of columns has no effect on anything other than the order they're returned in a select * query. The order defined doesn't even define the physical storage order.
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
October 3, 2008 at 1:06 pm
Thanks for clarifying that for me.
Jeremiah Peschka
Microsoft SQL Server MVP
Managing Director - Brent Ozar PLF, LLC
October 3, 2008 at 8:01 pm
And, yet, we so no testing nor references to Microsoft articles on the subject... does anyone have proof one way or the other? 😉
--Jeff Moden
Change is inevitable... Change for the better is not.
Viewing 5 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply