<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
		>
<channel>
	<title>Comments on: SQL SERVER &#8211; Introduction to Force Index Query Hints &#8211; Index Hint &#8211; Part2</title>
	<atom:link href="http://blog.sqlauthority.com/2009/02/08/sql-server-introduction-to-force-index-query-hints-index-hint-part2/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.sqlauthority.com/2009/02/08/sql-server-introduction-to-force-index-query-hints-index-hint-part2/</link>
	<description>Personal Notes of Pinal Dave</description>
	<lastBuildDate>Sat, 25 May 2013 01:31:40 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
	<item>
		<title>By: SQL SERVER &#8211; Weekly Series &#8211; Memory Lane &#8211; #015 &#171; SQL Server Journey with SQL Authority</title>
		<link>http://blog.sqlauthority.com/2009/02/08/sql-server-introduction-to-force-index-query-hints-index-hint-part2/#comment-419682</link>
		<dc:creator><![CDATA[SQL SERVER &#8211; Weekly Series &#8211; Memory Lane &#8211; #015 &#171; SQL Server Journey with SQL Authority]]></dc:creator>
		<pubDate>Sat, 09 Feb 2013 01:30:40 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=2281#comment-419682</guid>
		<description><![CDATA[[...] Introduction to Force Index Query Hints – Index Hint – Part2 [...]]]></description>
		<content:encoded><![CDATA[<p>[...] Introduction to Force Index Query Hints – Index Hint – Part2 [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: madhivanan</title>
		<link>http://blog.sqlauthority.com/2009/02/08/sql-server-introduction-to-force-index-query-hints-index-hint-part2/#comment-265587</link>
		<dc:creator><![CDATA[madhivanan]]></dc:creator>
		<pubDate>Wed, 21 Mar 2012 08:23:36 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=2281#comment-265587</guid>
		<description><![CDATA[However you can create primary key with clustered index at the time of declaring the table variable]]></description>
		<content:encoded><![CDATA[<p>However you can create primary key with clustered index at the time of declaring the table variable</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: JP</title>
		<link>http://blog.sqlauthority.com/2009/02/08/sql-server-introduction-to-force-index-query-hints-index-hint-part2/#comment-257152</link>
		<dc:creator><![CDATA[JP]]></dc:creator>
		<pubDate>Mon, 27 Feb 2012 07:25:20 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=2281#comment-257152</guid>
		<description><![CDATA[We cannot create index on table variables. But it is possible on temporary tables]]></description>
		<content:encoded><![CDATA[<p>We cannot create index on table variables. But it is possible on temporary tables</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: dan</title>
		<link>http://blog.sqlauthority.com/2009/02/08/sql-server-introduction-to-force-index-query-hints-index-hint-part2/#comment-125899</link>
		<dc:creator><![CDATA[dan]]></dc:creator>
		<pubDate>Fri, 01 Apr 2011 05:40:37 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=2281#comment-125899</guid>
		<description><![CDATA[I mean you cannot apply 
WITH (INDEX(index_name_here))

to the unique index in the table variable above

in fact how could we force sql server use the unique index when we know it would be more efficient then using a scan in the PK index

select * from @T where col2 = 2 
is not using the unique index]]></description>
		<content:encoded><![CDATA[<p>I mean you cannot apply<br />
WITH (INDEX(index_name_here))</p>
<p>to the unique index in the table variable above</p>
<p>in fact how could we force sql server use the unique index when we know it would be more efficient then using a scan in the PK index</p>
<p>select * from @T where col2 = 2<br />
is not using the unique index</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: madhivanan</title>
		<link>http://blog.sqlauthority.com/2009/02/08/sql-server-introduction-to-force-index-query-hints-index-hint-part2/#comment-125890</link>
		<dc:creator><![CDATA[madhivanan]]></dc:creator>
		<pubDate>Fri, 01 Apr 2011 05:23:39 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=2281#comment-125890</guid>
		<description><![CDATA[What did you mean by &quot;it does not have a name&quot;?]]></description>
		<content:encoded><![CDATA[<p>What did you mean by &#8220;it does not have a name&#8221;?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: dan</title>
		<link>http://blog.sqlauthority.com/2009/02/08/sql-server-introduction-to-force-index-query-hints-index-hint-part2/#comment-125868</link>
		<dc:creator><![CDATA[dan]]></dc:creator>
		<pubDate>Fri, 01 Apr 2011 00:27:21 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=2281#comment-125868</guid>
		<description><![CDATA[Hi

Could you please help me with this:
I have a table variable
DECLARE @T TABLE
(
  col1 INT NOT NULL PRIMARY KEY,
  col2 INT NOT NULL,
  filler CHAR(200) NOT NULL DEFAULT(&#039;a&#039;),
  unique(col2,col1)
);
how could I force using the unique index as it does not have a name]]></description>
		<content:encoded><![CDATA[<p>Hi</p>
<p>Could you please help me with this:<br />
I have a table variable<br />
DECLARE @T TABLE<br />
(<br />
  col1 INT NOT NULL PRIMARY KEY,<br />
  col2 INT NOT NULL,<br />
  filler CHAR(200) NOT NULL DEFAULT(&#8216;a&#8217;),<br />
  unique(col2,col1)<br />
);<br />
how could I force using the unique index as it does not have a name</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Nabil H Usmani</title>
		<link>http://blog.sqlauthority.com/2009/02/08/sql-server-introduction-to-force-index-query-hints-index-hint-part2/#comment-97871</link>
		<dc:creator><![CDATA[Nabil H Usmani]]></dc:creator>
		<pubDate>Thu, 04 Nov 2010 19:32:44 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=2281#comment-97871</guid>
		<description><![CDATA[Hi,

I am currently working on a project that requires me to dynamically build site navigation using recursive loop. Once a user select a category from navigation or provide a search keyword, the selected category/keyword acts as a filter to re-generate the entire navigation. 

I have the navigation listing generated and with every category in the navigation I need to put a count for the available recipes that lie under that category after applying the filters, i.e. if I have selected category 1 and 2, and I have a keyword &quot;chicken&quot; my query should re-generate the navigation and then along with each category it should put a count that tells me how many remaining recipes each category holds that is common in the selected filters cat 1 and 2, and also has a keyword chicken. 

I am using an intersect to pick the common recipes that exists in the provided filters (selected categories) and the category in the loop. The query I have gives accurate results but the execution time is too slow due to intersect. 


SELECT Categories.CategoryID, Categories.CategoryTitle, CategorySEO.PageTitle, 
	(SELECT Count(*) AS xCount 
	 FROM 
		(SELECT Count(ItemID) as xCount 
		 FROM Collections C WITH (INDEX(i__au_CategoryID))
		 INNER JOIN Recipes R WITH (INDEX(i__au_RecipeTitle)) ON C.ItemID = R.RecipeID 
		 WHERE C.CategoryID = Categories.CategoryID 
		 AND C.ItemID IN (
			(SELECT ItemID 
			 FROM Collections WITH (INDEX(i__au_CategoryID))
			 WHERE (CategoryID = 15)) --Category Filter 1
		INTERSECT 
			(SELECT ItemID 
			 FROM Collections WITH (INDEX(i__au_CategoryID))
			 WHERE (CategoryID = 125)) --Category Filter 2
		) 
		--GROUP BY C.ItemID
		AND R.RecipeTitle LIKE &#039;%chicken%&#039; --Keyword Filter
		GROUP BY C.ItemID,R.Active
		HAVING R.Active=1
		) AS derivedtbl_1
	) AS RecipeCount 
FROM Categories 
LEFT JOIN CategorySEO ON Categories.CategoryID = CategorySEO.CategoryID 
WHERE (Categories.ParentCategory = 2) AND (Categories.Active = 1) AND (Categories.CategoryTitle&#039;Uncategorized&#039;) 
ORDER BY Categories.CategoryID

As you can see I have applied indexing on columns categoryid and recipetitle. But doesn&#039;t seems to be giving any better performance.

Any thoughts?

Nabil]]></description>
		<content:encoded><![CDATA[<p>Hi,</p>
<p>I am currently working on a project that requires me to dynamically build site navigation using recursive loop. Once a user select a category from navigation or provide a search keyword, the selected category/keyword acts as a filter to re-generate the entire navigation. </p>
<p>I have the navigation listing generated and with every category in the navigation I need to put a count for the available recipes that lie under that category after applying the filters, i.e. if I have selected category 1 and 2, and I have a keyword &#8220;chicken&#8221; my query should re-generate the navigation and then along with each category it should put a count that tells me how many remaining recipes each category holds that is common in the selected filters cat 1 and 2, and also has a keyword chicken. </p>
<p>I am using an intersect to pick the common recipes that exists in the provided filters (selected categories) and the category in the loop. The query I have gives accurate results but the execution time is too slow due to intersect. </p>
<p>SELECT Categories.CategoryID, Categories.CategoryTitle, CategorySEO.PageTitle,<br />
	(SELECT Count(*) AS xCount<br />
	 FROM<br />
		(SELECT Count(ItemID) as xCount<br />
		 FROM Collections C WITH (INDEX(i__au_CategoryID))<br />
		 INNER JOIN Recipes R WITH (INDEX(i__au_RecipeTitle)) ON C.ItemID = R.RecipeID<br />
		 WHERE C.CategoryID = Categories.CategoryID<br />
		 AND C.ItemID IN (<br />
			(SELECT ItemID<br />
			 FROM Collections WITH (INDEX(i__au_CategoryID))<br />
			 WHERE (CategoryID = 15)) &#8211;Category Filter 1<br />
		INTERSECT<br />
			(SELECT ItemID<br />
			 FROM Collections WITH (INDEX(i__au_CategoryID))<br />
			 WHERE (CategoryID = 125)) &#8211;Category Filter 2<br />
		)<br />
		&#8211;GROUP BY C.ItemID<br />
		AND R.RecipeTitle LIKE &#8216;%chicken%&#8217; &#8211;Keyword Filter<br />
		GROUP BY C.ItemID,R.Active<br />
		HAVING R.Active=1<br />
		) AS derivedtbl_1<br />
	) AS RecipeCount<br />
FROM Categories<br />
LEFT JOIN CategorySEO ON Categories.CategoryID = CategorySEO.CategoryID<br />
WHERE (Categories.ParentCategory = 2) AND (Categories.Active = 1) AND (Categories.CategoryTitle&#8217;Uncategorized&#8217;)<br />
ORDER BY Categories.CategoryID</p>
<p>As you can see I have applied indexing on columns categoryid and recipetitle. But doesn&#8217;t seems to be giving any better performance.</p>
<p>Any thoughts?</p>
<p>Nabil</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: amit</title>
		<link>http://blog.sqlauthority.com/2009/02/08/sql-server-introduction-to-force-index-query-hints-index-hint-part2/#comment-86289</link>
		<dc:creator><![CDATA[amit]]></dc:creator>
		<pubDate>Thu, 02 Sep 2010 10:04:11 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=2281#comment-86289</guid>
		<description><![CDATA[Hi,

could you please let us explain on which columns we should create a clustered/non-clustered index on a table.
for example there is a query select col1,col2,col3, col4,col 5 from table1 where col3 &gt; 5 and col3 &lt; 10.
 and moreover, this query is used quite heavily for a specific dept, and i want to create a index on it, then which columns i should consider for creating index on this above table.]]></description>
		<content:encoded><![CDATA[<p>Hi,</p>
<p>could you please let us explain on which columns we should create a clustered/non-clustered index on a table.<br />
for example there is a query select col1,col2,col3, col4,col 5 from table1 where col3 &gt; 5 and col3 &lt; 10.<br />
 and moreover, this query is used quite heavily for a specific dept, and i want to create a index on it, then which columns i should consider for creating index on this above table.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Peter Kulek</title>
		<link>http://blog.sqlauthority.com/2009/02/08/sql-server-introduction-to-force-index-query-hints-index-hint-part2/#comment-58667</link>
		<dc:creator><![CDATA[Peter Kulek]]></dc:creator>
		<pubDate>Tue, 15 Dec 2009 15:22:07 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=2281#comment-58667</guid>
		<description><![CDATA[I am trying to do a select * with a filtered index and cannot get it to work. I want to use it similar to set the controlling index so that I can do a select * and only return the records in the index. Something like below.

SELECT *
FROM Person
WITH (INDEX(AK_Contact_rowguid))

Any clues as to how this can be achieved.]]></description>
		<content:encoded><![CDATA[<p>I am trying to do a select * with a filtered index and cannot get it to work. I want to use it similar to set the controlling index so that I can do a select * and only return the records in the index. Something like below.</p>
<p>SELECT *<br />
FROM Person<br />
WITH (INDEX(AK_Contact_rowguid))</p>
<p>Any clues as to how this can be achieved.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: mdma</title>
		<link>http://blog.sqlauthority.com/2009/02/08/sql-server-introduction-to-force-index-query-hints-index-hint-part2/#comment-46470</link>
		<dc:creator><![CDATA[mdma]]></dc:creator>
		<pubDate>Mon, 09 Feb 2009 09:04:24 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=2281#comment-46470</guid>
		<description><![CDATA[nice article, never knew it possible to do...
thanks]]></description>
		<content:encoded><![CDATA[<p>nice article, never knew it possible to do&#8230;<br />
thanks</p>
]]></content:encoded>
	</item>
</channel>
</rss>
