<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Jeremy Smyth's Blog &#187; Performance</title>
	<atom:link href="http://jeremysmyth.com/tag/performance/feed/" rel="self" type="application/rss+xml" />
	<link>http://jeremysmyth.com</link>
	<description></description>
	<lastBuildDate>Tue, 10 Aug 2010 12:07:42 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Tables, tables, tables</title>
		<link>http://jeremysmyth.com/2010/03/01/tables-tables-tables/</link>
		<comments>http://jeremysmyth.com/2010/03/01/tables-tables-tables/#comments</comments>
		<pubDate>Mon, 01 Mar 2010 17:29:02 +0000</pubDate>
		<dc:creator>Jeremy Smyth</dc:creator>
				<category><![CDATA[Databases]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[SQL Server 2005]]></category>
		<category><![CDATA[Performance]]></category>
		<category><![CDATA[SQL Server]]></category>

		<guid isPermaLink="false">http://jeremysmyth.com/?p=201</guid>
		<description><![CDATA[So, what&#8217;s a temporary table? or an in-memory table? or a pivot table?
An in-memory table is a table in some platforms that&#8217;s stored entirely in memory. These don&#8217;t really exist in MS SQL, although you could say that it is a table that&#8217;s been entirely cached, and so doesn&#8217;t result in any physical (hard disk) [...]]]></description>
			<content:encoded><![CDATA[<p>So, what&#8217;s a temporary table? or an in-memory table? or a pivot table?</p>
<p>An in-memory table is a table in some platforms that&#8217;s stored entirely in memory. These don&#8217;t really exist in MS SQL, although you could say that it is a table that&#8217;s been entirely cached, and so doesn&#8217;t result in any physical (hard disk) reads when queried. In earlier versions, the DBCC PINTABLE command allowed the &#8220;pinning&#8221; of tables in memory, but this was deprecated in SQL Server 2005.</p>
<p>Often, a table-valued variable, @tablename, might be stored in memory (although this is not guaranteed), and declared in a batch or function, with no persistence. </p>
<p>A temporary table is a table that will be automatically dropped when it&#8217;s no longer needed, usually when the creating session is terminated. In MS SQL, they begin with a # (or two hashes if they&#8217;re global temporary tables, shared between multiple sessions), and are often created with a <tt>SELECT INTO #TEMPTABLE</tt> &#8230; style query.</p>
<p>A pivot table is a special form of query where the values in several rows are summarised, &#8220;pivoted&#8221; on an axis, and become columns, where the summary data then becomes the rows. Frequently this happens where you&#8217;ve rows sorted on dates; these may then be &#8220;pivoted&#8221; so you end up with a column for January, one for February, one for March, etc.</p>
]]></content:encoded>
			<wfw:commentRss>http://jeremysmyth.com/2010/03/01/tables-tables-tables/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SQL: Why nulls slow down some queries</title>
		<link>http://jeremysmyth.com/2009/06/19/sql-why-nulls-slow-down-some-queries/</link>
		<comments>http://jeremysmyth.com/2009/06/19/sql-why-nulls-slow-down-some-queries/#comments</comments>
		<pubDate>Fri, 19 Jun 2009 21:56:46 +0000</pubDate>
		<dc:creator>Jeremy Smyth</dc:creator>
				<category><![CDATA[Databases]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[SQL Server 2005]]></category>
		<category><![CDATA[Nulls]]></category>
		<category><![CDATA[Performance]]></category>
		<category><![CDATA[SQL Server]]></category>

		<guid isPermaLink="false">http://jeremysmyth.com/?p=32</guid>
		<description><![CDATA[Someone asked a question on StackOverflow today about why null values slow down certain queries. This is roughly what I answered.
The main issue with null values and performance is to do with forward lookups.
If you insert a row into a table, with null values, it&#8217;s placed in the natural page that it belongs to. Any [...]]]></description>
			<content:encoded><![CDATA[<p>Someone asked a question on StackOverflow today about why null values slow down certain queries. This is roughly what I answered.</p>
<p>The main issue with null values and performance is to do with forward lookups.</p>
<p>If you insert a row into a table, with null values, it&#8217;s placed in the natural page that it belongs to. Any query looking for that record will find it in the appropriate place. Easy so far&#8230;.</p>
<p>&#8230;but let&#8217;s say the page fills up, and now that row is cuddled in amongst the other rows. Still going well&#8230;</p>
<p>&#8230;until the row is updated, and the null value now contains something. The row&#8217;s size has increased beyond the space available to it, so the DB engine has to do something about it.</p>
<p>The fastest thing for the server to do is to move the row off that page into another, and to replace the row&#8217;s entry with a forward pointer. Unfortunately, this requires an extra lookup when a query is performed: one to find the natural location of the row, and one to find its current location.</p>
<p>So, the short answer to the question of performance is yes, making those fields non-nullable will help search performance. This is especially true if it often happens that the null fields in records you search on are updated to non-null.</p>
<p>Of course, there are other penalties (notably I/O, although to a tiny extent index depth) associated with larger datasets, and then you have application issues with disallowing nulls in fields that conceptually require them, but hey, that&#8217;s another problem!</p>
]]></content:encoded>
			<wfw:commentRss>http://jeremysmyth.com/2009/06/19/sql-why-nulls-slow-down-some-queries/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
