<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://msmvps.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Rob Farley : sql improvements</title><link>http://msmvps.com/blogs/robfarley/archive/tags/sql+improvements/default.aspx</link><description>Tags: sql improvements</description><dc:language>en</dc:language><generator>CommunityServer 2008.5 SP2 (Build: 40407.4157)</generator><item><title>High ROI items for SQL Server 2008</title><link>http://msmvps.com/blogs/robfarley/archive/2009/12/18/high-roi-items-for-sql-server-2008.aspx</link><pubDate>Thu, 17 Dec 2009 23:02:00 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1745828</guid><dc:creator>Rob Farley</dc:creator><slash:comments>2</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://msmvps.com/blogs/robfarley/rsscomments.aspx?PostID=1745828</wfw:commentRss><comments>http://msmvps.com/blogs/robfarley/archive/2009/12/18/high-roi-items-for-sql-server-2008.aspx#comments</comments><description>&lt;p&gt;To persuade your boss to embrace an upgrade to SQL 2008, you need to know which features have high Return On Investment. They may have seen presentations talking about features like Spatial, or MERGE (and been quite impressed), but they may well have left those presentations thinking about the effort that’s would be involved in rewriting applications to take advantage of these features. It’s all well and good to see your customers on a map, but someone has to make that spatial data appear somewhere.&lt;/p&gt;  &lt;p&gt;This post is a callout for features that will benefit you (and your boss) as soon as you do the upgrade (or soon after). And I welcome comments to list other items as well.&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;strong&gt;Block Computation &lt;/strong&gt;(in SSAS – which reduces the effort in processing significantly, for no change in the application )&lt;/li&gt;    &lt;li&gt;&lt;strong&gt;Transparent Data Encryption &lt;/strong&gt;(in the Database Engine – which makes sure that data at rest is encrypted, with no change in the application)&lt;/li&gt;    &lt;li&gt;&lt;strong&gt;Backup Compression &lt;/strong&gt;(which reduces the size of backups, and can be set as the default so that existing backup scripts don’t need to change)&lt;/li&gt;    &lt;li&gt;&lt;strong&gt;Data Compression &lt;/strong&gt;(minimal change to turn on compression on tables which will compress nicely)&lt;/li&gt;    &lt;li&gt;&lt;strong&gt;Filtered Indexes &lt;/strong&gt;(because how far off is your next index creation, really?)&lt;/li&gt;    &lt;li&gt;&lt;strong&gt;Auditing &lt;/strong&gt;&amp;amp; &lt;strong&gt;Change Data Tracking &lt;/strong&gt;(because it’s very easy to turn on and then review the data as you need it)&lt;/li&gt;    &lt;li&gt;&lt;strong&gt;Export to Word in SSRS &lt;/strong&gt;(because everyone’s wanted this for so long)&lt;/li&gt;    &lt;li&gt;&lt;strong&gt;SSRS paging &lt;/strong&gt;(because SSRS used to get _all_ the data for a report before rendering it – but not in 2008)&lt;/li&gt;    &lt;li&gt;&lt;strong&gt;Resource Governor&lt;/strong&gt; (easy to set up, nice to have in place for when you might want it)&lt;/li&gt;    &lt;li&gt;&lt;strong&gt;Hot-add memory&lt;/strong&gt; (so that you can just plug in more memory without having to do restarts)&lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;I’m not suggesting that an upgrade should be done flippantly. You should still consider the effort of thoroughly testing your system under SQL 2008. But hopefully this list can highlight some of the things that I’ve found are good persuaders. A list of “What’s New in SQL 2008” can be found at &lt;a title="http://www.microsoft.com/sqlserver/2008/en/us/whats-new.aspx" href="http://www.microsoft.com/sqlserver/2008/en/us/whats-new.aspx"&gt;http://www.microsoft.com/sqlserver/2008/en/us/whats-new.aspx&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Like I said, you may have other items on your own list, and I invite you to comment on this. You may also have things in place to handle things like encryption, and you may be running Hyperbac or one of the other compression tools.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1745828" width="1" height="1"&gt;</description><category domain="http://msmvps.com/blogs/robfarley/archive/tags/sql/default.aspx">sql</category><category domain="http://msmvps.com/blogs/robfarley/archive/tags/sql+server+2008/default.aspx">sql server 2008</category><category domain="http://msmvps.com/blogs/robfarley/archive/tags/sql+improvements/default.aspx">sql improvements</category></item><item><title>Missing Index in SQL Server 2008 - should try harder!</title><link>http://msmvps.com/blogs/robfarley/archive/2008/10/12/missing-index-in-sql-server-2008-should-try-harder.aspx</link><pubDate>Sun, 12 Oct 2008 03:38:48 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1650606</guid><dc:creator>Rob Farley</dc:creator><slash:comments>12</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://msmvps.com/blogs/robfarley/rsscomments.aspx?PostID=1650606</wfw:commentRss><comments>http://msmvps.com/blogs/robfarley/archive/2008/10/12/missing-index-in-sql-server-2008-should-try-harder.aspx#comments</comments><description>&lt;p&gt;Ok, maybe I&amp;#39;m being a little harsh, but I just feel like it should be better.&lt;/p&gt; &lt;p&gt;Let me show you the niceness of the way that missing indexes are handled in SQL Server 2008. &lt;/p&gt; &lt;p&gt;Using AdventureWorks (not AdventureWorks2008) on a SQL Server 2008 install, if I show the Execution Plan from this simple query, I get a nice suggestion. My query...&lt;/p&gt; &lt;blockquote&gt; &lt;p&gt;&lt;em&gt;select productid, orderqty &lt;br /&gt;from sales.salesorderdetail&lt;br /&gt;where carriertrackingnumber = &amp;#39;FB88-4B92-82&amp;#39;;&lt;/em&gt;&lt;/p&gt;&lt;/blockquote&gt; &lt;p&gt;...could be improved through better indexing. It uses 1240 reads to get this data, which seems awful. The system shows me that it could be improved, and suggests an index.  &lt;p&gt;&lt;img style="border-top-width:0px;border-left-width:0px;border-bottom-width:0px;border-right-width:0px;" height="389" alt="image" src="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/robfarley.MissingIndexinSQLServer2008shouldtryhard_5F00_CD94/image_5F00_6.png" width="644" border="0" /&gt;  &lt;p&gt;It&amp;#39;s there, in green. It says:&lt;/p&gt; &lt;blockquote&gt; &lt;p&gt;&lt;em&gt;CREATE NONCLUSTERED INDEX [&amp;lt;Name of Missing Index, sysname,&amp;gt;] ON [Sales].[SalesOrderDetail] ([CarrierTrackingNumber])&lt;/em&gt;&lt;/p&gt;&lt;/blockquote&gt; &lt;p&gt;(that&amp;#39;s right, no semi-colon on the end, but I&amp;#39;m fine about that)&lt;/p&gt; &lt;p&gt;What I&amp;#39;m not fine with is the fact that this index isn&amp;#39;t actually so ideal. If I create it (supplying a name, of course), we see it&amp;#39;s being used, and it should be clear that a better index ought to be better.&lt;/p&gt; &lt;p&gt;&lt;img style="border-top-width:0px;border-left-width:0px;border-bottom-width:0px;border-right-width:0px;" height="389" alt="image" src="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/robfarley.MissingIndexinSQLServer2008shouldtryhard_5F00_CD94/image_5F00_5.png" width="644" border="0" /&gt; &lt;/p&gt; &lt;p&gt;This query uses 42 reads to get the required information, which is significantly better than 1740, but still not brilliant. In fact, 42 is about 2.4% of 1740, so it&amp;#39;s hardly the 99.6512% improvement that Management Studio suggested would be seen.&lt;/p&gt; &lt;p&gt;My preference would be to consider that Key Lookup as well. it&amp;#39;s taking 92% of this improved query. We can avoid the Key Lookup by creating an index which INCLUDEs the columns we&amp;#39;re interested in. Like this:&lt;/p&gt; &lt;blockquote&gt; &lt;p&gt;&lt;em&gt;CREATE NONCLUSTERED INDEX [MyNewIndex2] ON [Sales].[SalesOrderDetail] ([CarrierTrackingNumber]) INCLUDE (ProductID, OrderQty);&lt;/em&gt;&lt;/p&gt;&lt;/blockquote&gt; &lt;p&gt;If I create this index, we see that the execution plan becomes just the Index Seek (on my new index), and the number of reads drops to just 3. Yes 3. That&amp;#39;s 0.17% of the original query, and only 7.1% of the reads of the improved query! 99.83% of the original reads have been eliminated - much more like the figures promised by my Missing Index suggestion, except it got it wrong.  &lt;p&gt;&lt;img style="border-top-width:0px;border-left-width:0px;border-bottom-width:0px;border-right-width:0px;" height="389" alt="image" src="http://msmvps.com/cfs-file.ashx/__key/CommunityServer.Blogs.Components.WeblogFiles/robfarley.MissingIndexinSQLServer2008shouldtryhard_5F00_CD94/image_5F00_9.png" width="644" border="0" /&gt;  &lt;p&gt;I like the idea of detecting Missing Indexes, and I love the fact that it suggests these in Execution Plan viewer... I just want it to be slightly better by considering INCLUDEd columns.  &lt;p&gt;I&amp;#39;ve suggested this be improved on the Connect site at &lt;a title="https://connect.microsoft.com/SQLServer/feedback/ViewFeedback.aspx?FeedbackID=375024" href="https://connect.microsoft.com/SQLServer/feedback/ViewFeedback.aspx?FeedbackID=375024" target="_blank"&gt;https://connect.microsoft.com/SQLServer/feedback/ViewFeedback.aspx?FeedbackID=375024&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1650606" width="1" height="1"&gt;</description><category domain="http://msmvps.com/blogs/robfarley/archive/tags/sql/default.aspx">sql</category><category domain="http://msmvps.com/blogs/robfarley/archive/tags/sql+server+2008/default.aspx">sql server 2008</category><category domain="http://msmvps.com/blogs/robfarley/archive/tags/sql+improvements/default.aspx">sql improvements</category></item><item><title>Ctrl+1 in SSMS for sp_who, plus more</title><link>http://msmvps.com/blogs/robfarley/archive/2008/08/08/ctrl-1-in-ssms-for-sp-who-plus-more.aspx</link><pubDate>Thu, 07 Aug 2008 13:55:48 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1643715</guid><dc:creator>Rob Farley</dc:creator><slash:comments>2</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://msmvps.com/blogs/robfarley/rsscomments.aspx?PostID=1643715</wfw:commentRss><comments>http://msmvps.com/blogs/robfarley/archive/2008/08/08/ctrl-1-in-ssms-for-sp-who-plus-more.aspx#comments</comments><description>&lt;p&gt;I did this by accident, but turns out it&amp;#39;s a really useful feature. I was just trying to zoom in on something using &lt;a href="http://technet.microsoft.com/en-us/sysinternals/bb897434.aspx" target="_blank"&gt;Zoomit&lt;/a&gt;, that really useful thing that I use whenever I&amp;#39;m presenting these days. But I didn&amp;#39;t have Zoomit running, and so SQL Server Management Studio ran sp_who.&lt;/p&gt; &lt;p&gt;And it&amp;#39;s not even new. This is an old Query Analyzer thing - I just hadn&amp;#39;t come across it before. And it&amp;#39;s extensible! Go to Tools, Options, Environment, Keyboard. By default, sp_who is Ctrl+1, sp_lock is Ctrl+2 and sp_help is Alt+F1 (which runs on whatever you have highlighted). Then pick one of the ones that you&amp;#39;re allowed to set for yourself, and put a command in. I can&amp;#39;t believe I haven&amp;#39;t stumbled across it before. I&amp;#39;ve already put sp_helpindex on Ctrl+3, and sp_helptext on Ctrl+4.&lt;/p&gt; &lt;p&gt;The only complaint I have about it is that if you select a two-part object name and hit Alt+F1 (the shortcut for sp_help), it fails because there aren&amp;#39;t quotes around the name. I&amp;#39;d like to be able to wrap stuff up, to make it do &amp;quot;sp_help &amp;#39;*&amp;#39;&amp;quot;, where the star refers to the selected text. I thought this would be worthy of posting to Connect, but Michael Swart has already posted &lt;a href="https://connect.microsoft.com/SQLServer/feedback/ViewFeedback.aspx?FeedbackID=349116" target="_blank"&gt;something similar&lt;/a&gt;. No-one&amp;#39;s voted on this yet, but I think it could be really useful (so please, go vote. Put comments in, all kinds of stuff). Great to be able to call sp_helpindex when highlighting a table (I&amp;#39;ve just added this one), but if this breaks whenever I need to specify a schema, then it&amp;#39;s just a little less useful. I&amp;#39;d even like to be able to have something which runs a whole query, using my highlighted text somewhere in there.&lt;/p&gt; &lt;p&gt;At the moment I&amp;#39;m playing around with having a keyboard shortcut for:&lt;/p&gt; &lt;p&gt;&lt;em&gt;select * from sys.dm_db_index_usage_stats&lt;/em&gt;&lt;/p&gt; &lt;p&gt;and then highlighting:&lt;/p&gt; &lt;p&gt;&lt;em&gt;where object_id = object_id(&amp;#39;sales.salesorderheader&amp;#39;)&lt;/em&gt;&lt;/p&gt; &lt;p&gt;What do you have on your keyboard shortcuts?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1643715" width="1" height="1"&gt;</description><category domain="http://msmvps.com/blogs/robfarley/archive/tags/sql/default.aspx">sql</category><category domain="http://msmvps.com/blogs/robfarley/archive/tags/sql+improvements/default.aspx">sql improvements</category></item><item><title>Design Query in Editor bug</title><link>http://msmvps.com/blogs/robfarley/archive/2008/07/03/design-query-in-editor-bug.aspx</link><pubDate>Thu, 03 Jul 2008 08:28:47 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1639216</guid><dc:creator>Rob Farley</dc:creator><slash:comments>1</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://msmvps.com/blogs/robfarley/rsscomments.aspx?PostID=1639216</wfw:commentRss><comments>http://msmvps.com/blogs/robfarley/archive/2008/07/03/design-query-in-editor-bug.aspx#comments</comments><description>&lt;p&gt;Ok, so real database developers don&amp;#39;t use the graphical &amp;quot;Design Query in Editor&amp;quot;... yeah, I know. Sure, there&amp;#39;s the odd time when you&amp;#39;re typing a query and you don&amp;#39;t have an Object Explorer (eg, in SSIS) and a moment of weakness sees you hit &amp;quot;Build Query&amp;quot; to save some typing, but in general I encourage people to write their queries in Management Studio SSMS and then copy them into the SSIS dialog. I was showing someone some of the frustrations I have with the graphical editor, and came across a real beauty - repeated predicates.&lt;/p&gt; &lt;p&gt;I logged a bug at the Connect site, where I wrote the rest of the details. You should vote for this - there may be a time when you click &amp;quot;Build Query&amp;quot; to avoid some typing, and you don&amp;#39;t want to look like an idiot for repeating the same line multiple times.&lt;/p&gt; &lt;p&gt;&lt;a title="https://connect.microsoft.com/SQLServer/feedback/ViewFeedback.aspx?FeedbackID=352874" href="https://connect.microsoft.com/SQLServer/feedback/ViewFeedback.aspx?FeedbackID=352874"&gt;https://connect.microsoft.com/SQLServer/feedback/ViewFeedback.aspx?FeedbackID=352874&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1639216" width="1" height="1"&gt;</description><category domain="http://msmvps.com/blogs/robfarley/archive/tags/sql/default.aspx">sql</category><category domain="http://msmvps.com/blogs/robfarley/archive/tags/sql+improvements/default.aspx">sql improvements</category><category domain="http://msmvps.com/blogs/robfarley/archive/tags/ssis/default.aspx">ssis</category></item><item><title>Fuzzy in T-SQL</title><link>http://msmvps.com/blogs/robfarley/archive/2008/04/18/fuzzy-in-t-sql.aspx</link><pubDate>Thu, 17 Apr 2008 14:49:49 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1592356</guid><dc:creator>Rob Farley</dc:creator><slash:comments>1</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://msmvps.com/blogs/robfarley/rsscomments.aspx?PostID=1592356</wfw:commentRss><comments>http://msmvps.com/blogs/robfarley/archive/2008/04/18/fuzzy-in-t-sql.aspx#comments</comments><description>&lt;p&gt;SQL Server gives you &lt;a href="http://msdn2.microsoft.com/en-us/library/ms345128.aspx" target="_blank"&gt;Fuzzy Lookups and Fuzzy Grouping&lt;/a&gt;, but only in SQL Server Integration Services. It&amp;#39;s not even on the list of SSIS enhancements for SQL Server 2008.&lt;/p&gt; &lt;p&gt;This week at the MVP Summit, I was having a discussion about this with &lt;a href="http://blogs.conchango.com/jamiethomson/" target="_blank"&gt;Jamie Thomson&lt;/a&gt;, and we had a chat with one of the T-SQL guys to suggest it. The response came back with &amp;quot;Log in on connect&amp;quot;, which I did just now. &lt;a title="https://connect.microsoft.com/SQLServer/feedback/ViewFeedback.aspx?FeedbackID=338664" href="https://connect.microsoft.com/SQLServer/feedback/ViewFeedback.aspx?FeedbackID=338664"&gt;https://connect.microsoft.com/SQLServer/feedback/ViewFeedback.aspx?FeedbackID=338664&lt;/a&gt;&lt;/p&gt; &lt;p&gt;Please check it out and provide comments, votes, validations. All this will help persuade Microsoft to implement this useful feature. And tell your friends too! The more it receives, the more likely it will be implemented.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://msmvps.com/aggbug.aspx?PostID=1592356" width="1" height="1"&gt;</description><category domain="http://msmvps.com/blogs/robfarley/archive/tags/sql+server+2008/default.aspx">sql server 2008</category><category domain="http://msmvps.com/blogs/robfarley/archive/tags/sql+improvements/default.aspx">sql improvements</category></item></channel></rss>