<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	
	>
<channel>
	<title>
	Comments on: The Query Optimizer’s handling of Relationships for T-SQL Tuesday #003	</title>
	<atom:link href="https://lobsterpot.com.au/blog/2010/02/09/the-query-optimizer-s-handling-of-relationships-for-t-sql-tuesday-003/feed/" rel="self" type="application/rss+xml" />
	<link>https://lobsterpot.com.au/blog/2010/02/09/the-query-optimizer-s-handling-of-relationships-for-t-sql-tuesday-003/</link>
	<description></description>
	<lastBuildDate>Sun, 14 Feb 2010 05:51:39 +0000</lastBuildDate>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=7.1.3</generator>
	<item>
		<title>
		By: Rob Farley		</title>
		<link>https://lobsterpot.com.au/blog/2010/02/09/the-query-optimizer-s-handling-of-relationships-for-t-sql-tuesday-003/#comment-942</link>

		<dc:creator><![CDATA[Rob Farley]]></dc:creator>
		<pubDate>Sun, 14 Feb 2010 05:51:39 +0000</pubDate>
		<guid isPermaLink="false">/blogs/robfarley/archive/2010/02/09/the-query-optimizer-s-handling-of-relationships-for-t-sql-tuesday-003.aspx#comment-942</guid>

					<description><![CDATA[@Joe – Thanks for that. I didn’t realise that, and it makes for some interesting thoughts. I do wish that SQL Server did it that way – perhaps at some point it might, or maybe that’s just a pipe dream.

@RobLobbe – Sorry, we’ll have to disagree on that one. I’ve seen too many situations where the Query Optimizer has been able to run a query so much better because a Foreign Key is in place. I’ve also seen too many situations where a database without FKs has referential integrity issues, and I would always want my Test and Production systems to be identical. Thanks for commenting though – it’s always good to hear other perspectives.]]></description>
			<content:encoded><![CDATA[<p>@Joe – Thanks for that. I didn’t realise that, and it makes for some interesting thoughts. I do wish that SQL Server did it that way – perhaps at some point it might, or maybe that’s just a pipe dream.</p>
<p>@RobLobbe – Sorry, we’ll have to disagree on that one. I’ve seen too many situations where the Query Optimizer has been able to run a query so much better because a Foreign Key is in place. I’ve also seen too many situations where a database without FKs has referential integrity issues, and I would always want my Test and Production systems to be identical. Thanks for commenting though – it’s always good to hear other perspectives.</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Rob Lobbe		</title>
		<link>https://lobsterpot.com.au/blog/2010/02/09/the-query-optimizer-s-handling-of-relationships-for-t-sql-tuesday-003/#comment-941</link>

		<dc:creator><![CDATA[Rob Lobbe]]></dc:creator>
		<pubDate>Sun, 14 Feb 2010 05:35:24 +0000</pubDate>
		<guid isPermaLink="false">/blogs/robfarley/archive/2010/02/09/the-query-optimizer-s-handling-of-relationships-for-t-sql-tuesday-003.aspx#comment-941</guid>

					<description><![CDATA[Foreign Keys are a DESIGN tool. And should be treated as such. As far as the Query Optimizer goes, it should NEVER be an issue in my production database. FK’s should be removed, as they only cause overhead to day-to-day processing.
It the feature of an application is to ‘display an error for every FK breach’ the vendor’s going to get an earful for a shoddy product. Likewise if the product is relying on a cascade delete, what else are they ‘guessing’ at – especial if I want audit’s and history retention.
In a development, or testing environment, sure put them in. They make sure the application doesn’t break the rules, but from an optimizer standpoint I’m not concerned with this overhead – the final product will be that much better, without them.]]></description>
			<content:encoded><![CDATA[<p>Foreign Keys are a DESIGN tool. And should be treated as such. As far as the Query Optimizer goes, it should NEVER be an issue in my production database. FK’s should be removed, as they only cause overhead to day-to-day processing.<br />
It the feature of an application is to ‘display an error for every FK breach’ the vendor’s going to get an earful for a shoddy product. Likewise if the product is relying on a cascade delete, what else are they ‘guessing’ at – especial if I want audit’s and history retention.<br />
In a development, or testing environment, sure put them in. They make sure the application doesn’t break the rules, but from an optimizer standpoint I’m not concerned with this overhead – the final product will be that much better, without them.</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Joe Celko		</title>
		<link>https://lobsterpot.com.au/blog/2010/02/09/the-query-optimizer-s-handling-of-relationships-for-t-sql-tuesday-003/#comment-940</link>

		<dc:creator><![CDATA[Joe Celko]]></dc:creator>
		<pubDate>Sun, 14 Feb 2010 02:06:05 +0000</pubDate>
		<guid isPermaLink="false">/blogs/robfarley/archive/2010/02/09/the-query-optimizer-s-handling-of-relationships-for-t-sql-tuesday-003.aspx#comment-940</guid>

					<description><![CDATA[FYI

Sybase and other SQLs implement the PK-FK relationships as pointer chains that connect the FK to the single PK value in the entire schema. They think of the schema as a whole. You can see the advantages of this for CASCADE, JOIN and other operations.

SQL Server and other lesser SQLs implement each table separately as if they were files, so the PK value is repeated over and over in the FK columns. To get good join performance, you usually index FKs in such products.

SQLs that use hashing actually want longer keys because they hash with fewer collisions.]]></description>
			<content:encoded><![CDATA[<p>FYI</p>
<p>Sybase and other SQLs implement the PK-FK relationships as pointer chains that connect the FK to the single PK value in the entire schema. They think of the schema as a whole. You can see the advantages of this for CASCADE, JOIN and other operations.</p>
<p>SQL Server and other lesser SQLs implement each table separately as if they were files, so the PK value is repeated over and over in the FK columns. To get good join performance, you usually index FKs in such products.</p>
<p>SQLs that use hashing actually want longer keys because they hash with fewer collisions.</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Jeremiah Peschka		</title>
		<link>https://lobsterpot.com.au/blog/2010/02/09/the-query-optimizer-s-handling-of-relationships-for-t-sql-tuesday-003/#comment-939</link>

		<dc:creator><![CDATA[Jeremiah Peschka]]></dc:creator>
		<pubDate>Tue, 09 Feb 2010 20:34:49 +0000</pubDate>
		<guid isPermaLink="false">/blogs/robfarley/archive/2010/02/09/the-query-optimizer-s-handling-of-relationships-for-t-sql-tuesday-003.aspx#comment-939</guid>

					<description><![CDATA[I’m guessing you’re referring to the difference between using a surrogate key and a superkey. I make that guess because if your PK is on a natural candidate key, it wouldn’t be a question.

As long as the unique index has all included columns for queries (effectively making it a second clustered index), I would say that it’s probably a better candidate for the FK than the artificial PK.

While we’re frequently told we should use surrogate PKs, isn’t it more important to balance logic and reason (referencing the natural candidate key) with convenience (referencing the surrogate key). A pure relational theorist, of course, would say to use the natural key. I’ve used with both and haven’t seen appreciable differences in application performance. These days the choice comes down to what my predecessor has done.]]></description>
			<content:encoded><![CDATA[<p>I’m guessing you’re referring to the difference between using a surrogate key and a superkey. I make that guess because if your PK is on a natural candidate key, it wouldn’t be a question.</p>
<p>As long as the unique index has all included columns for queries (effectively making it a second clustered index), I would say that it’s probably a better candidate for the FK than the artificial PK.</p>
<p>While we’re frequently told we should use surrogate PKs, isn’t it more important to balance logic and reason (referencing the natural candidate key) with convenience (referencing the surrogate key). A pure relational theorist, of course, would say to use the natural key. I’ve used with both and haven’t seen appreciable differences in application performance. These days the choice comes down to what my predecessor has done.</p>
]]></content:encoded>
		
			</item>
	</channel>
</rss>
