﻿<?xml version='1.0' encoding='UTF-8'?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>SQLServerCentral / Article Discussions / Discuss content posted by Thom / Article Discussions by Author  / Unexpected View Performance / Latest Posts</title><generator>InstantForum.NET v2.9.0</generator><description>SQLServerCentral</description><link>http://www.sqlservercentral.com/Forums/</link><webMaster>notifications@sqlservercentral.com</webMaster><lastBuildDate>Sat, 25 May 2013 04:25:49 GMT</lastBuildDate><ttl>20</ttl><item><title>RE: Unexpected View Performance</title><link>http://www.sqlservercentral.com/Forums/Topic1045669-580-1.aspx</link><description>I found this absolutely fascinating.  Little things like this can sometimes cost days of extra work.  Thank you for sharing.  I am pretty sure it will save me some headaches down the road.</description><pubDate>Wed, 12 Jan 2011 12:43:42 GMT</pubDate><dc:creator>mishaluba</dc:creator></item><item><title>RE: Unexpected View Performance</title><link>http://www.sqlservercentral.com/Forums/Topic1045669-580-1.aspx</link><description>Thanks for sharing your observation.Now we know that 'near-enough' may be a long way from 'identical' when it comes to datatypes:-)</description><pubDate>Wed, 12 Jan 2011 05:43:12 GMT</pubDate><dc:creator>SQLCharger</dc:creator></item><item><title>RE: Unexpected View Performance</title><link>http://www.sqlservercentral.com/Forums/Topic1045669-580-1.aspx</link><description>Nice article. This is a good example of just a single typo or miss in declaring the column data type/length can harm your performance and you need to spend a week to resolve the issue.</description><pubDate>Tue, 11 Jan 2011 12:06:18 GMT</pubDate><dc:creator>Hardy21</dc:creator></item><item><title>RE: Unexpected View Performance</title><link>http://www.sqlservercentral.com/Forums/Topic1045669-580-1.aspx</link><description>The statement executed outside of the view is the one below, filter added to both of the select statements.SELECT accountnumber FROM agents2009 WHERE accountnumber = ''QOT039365'UNION ALLSELECT accountnumber FROM agents WHERE accountnumber = ''QOT039365'Hope this help clears up the question.</description><pubDate>Tue, 11 Jan 2011 08:30:47 GMT</pubDate><dc:creator>Thom_Bolin</dc:creator></item><item><title>RE: Unexpected View Performance</title><link>http://www.sqlservercentral.com/Forums/Topic1045669-580-1.aspx</link><description>Thanks for posting this.  I found it very insightful and relieving because I thought I was the only person that missed things like this.  It took you a long time to figure this one out (it would have taken me longer) and it's so close to the surface I bet you even gave it a thought in the beginning.  I can almost see the process..."Hmmm...it's gotta be an index.  Perhaps this Varchar(9) and Varchar(10) thing would be an issue....NAH, you can't get any closer to matching datatypes than that!"At least, that's how my brain would have seen it.  Then, it would have been the absolute LAST thing I tried, because, "there's NO WAY a varchar(9) and varchar(10) would make a difference".Again, thanks for posting and making your findings clear and concise (nice code and screenshots).Gabe</description><pubDate>Tue, 11 Jan 2011 08:02:20 GMT</pubDate><dc:creator>thisisfutile</dc:creator></item><item><title>RE: Unexpected View Performance</title><link>http://www.sqlservercentral.com/Forums/Topic1045669-580-1.aspx</link><description>There are sooooo many ways using inconsistent datatypes can harm performance!  I have been preaching this to clients (and cleaning up messes related to it) for over a decade now!! :-)</description><pubDate>Tue, 11 Jan 2011 07:52:14 GMT</pubDate><dc:creator>TheSQLGuru</dc:creator></item><item><title>RE: Unexpected View Performance</title><link>http://www.sqlservercentral.com/Forums/Topic1045669-580-1.aspx</link><description>Hi AllThe main reason for degradation in performance here is that the query filter was not supplied in the exact format that index was created in.To be honest this doesnt really have all that much to do with the fact that you are querying data from a view. If you want sql to use an index in its query plan the filter must be supplied in exactly  the same format as the column  indexed on the   tableif the index is built on a column of type smallint and you sent in an int as a filter the plan will use a full table scan instead of an index seek</description><pubDate>Tue, 11 Jan 2011 07:14:35 GMT</pubDate><dc:creator>Brian Brenner-395976</dc:creator></item><item><title>RE: Unexpected View Performance</title><link>http://www.sqlservercentral.com/Forums/Topic1045669-580-1.aspx</link><description>"This same statement executed outside of the view uses an Index Seek on both tables."Like you, I get the same plan as the view with a select from a derived table.  However, seeks do occur against both tables if separate WHERE clauses are specified with each SELECT of the UNION ALL.  So I am guessing that it wasn't really the same statement that Thom ran from SSMS:SELECT accountnumber FROM agents2009WHERE accountnumber = 'QOT039365'UNION ALLSELECT accountnumber FROM agentsWHERE accountnumber = 'QOT039365';</description><pubDate>Tue, 11 Jan 2011 05:47:22 GMT</pubDate><dc:creator>Dan Guzman-481633</dc:creator></item><item><title>RE: Unexpected View Performance</title><link>http://www.sqlservercentral.com/Forums/Topic1045669-580-1.aspx</link><description>Hi,Can you draw the conclusion in other words ?</description><pubDate>Tue, 11 Jan 2011 04:40:45 GMT</pubDate><dc:creator>pandeharsh</dc:creator></item><item><title>RE: Unexpected View Performance</title><link>http://www.sqlservercentral.com/Forums/Topic1045669-580-1.aspx</link><description>Hello,Thanks for writing this article, in my search for a solution of a performance problem I ran into your post and it has helped me partly so far. I do have a question though:You're saying "This same statement executed outside of the view uses an Index Seek on both tables.", can you show what statement that is? If I try:SELECT accountnumber FROM (	SELECT accountnumber FROM agents2009	UNION ALL	SELECT accountnumber FROM agents)vwInline WHERE accountnumber = 'QOT039365' I don't see any difference in the queryplan from replacing the subquery with the view.regards,Sebastiaan</description><pubDate>Tue, 11 Jan 2011 00:32:53 GMT</pubDate><dc:creator>sebastocrator</dc:creator></item><item><title>Unexpected View Performance</title><link>http://www.sqlservercentral.com/Forums/Topic1045669-580-1.aspx</link><description>Comments posted to this topic are about the item [B]&lt;A HREF="/articles/Views/71787/"&gt;Unexpected View Performance&lt;/A&gt;[/B]</description><pubDate>Mon, 10 Jan 2011 20:11:19 GMT</pubDate><dc:creator>Thom_Bolin</dc:creator></item></channel></rss>