﻿<?xml version='1.0' encoding='UTF-8'?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>SQLServerCentral / SQL Server 2008 / SQL Server Newbies  / How to set index for these select queries / 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>Wed, 19 Jun 2013 11:53:29 GMT</lastBuildDate><ttl>20</ttl><item><title>RE: How to set index for these select queries</title><link>http://www.sqlservercentral.com/Forums/Topic1408195-1292-1.aspx</link><description>@duration is negative number....like -1,-2,-3</description><pubDate>Fri, 18 Jan 2013 04:08:17 GMT</pubDate><dc:creator>prakash.kumar3669</dc:creator></item><item><title>RE: How to set index for these select queries</title><link>http://www.sqlservercentral.com/Forums/Topic1408195-1292-1.aspx</link><description>[quote]WHERE SomeNumber &amp;gt;=0 AND SomeNumber &amp;lt; 0[/quote]this is the actual condition: SubmitDate&amp;gt;=DATEADD(day,DATEDIFF(day,0,GETDATE()),@duration) AND SubmitDate &amp;lt; DATEADD(day,DATEDIFF(day,0,GETDATE()),1)</description><pubDate>Fri, 18 Jan 2013 04:06:05 GMT</pubDate><dc:creator>prakash.kumar3669</dc:creator></item><item><title>RE: How to set index for these select queries</title><link>http://www.sqlservercentral.com/Forums/Topic1408195-1292-1.aspx</link><description>[quote][b]prakash.kumar3669 (1/17/2013)[/b][hr][quote][b]GilaMonster (1/17/2013)[/b][hr]Index on (IsDeleted, SubmitDate DESC) include (ProdName,Category,TotalStock,Price)[/quote]What would be the exact sql query to create the index.[/quote]Why don't you open up books online and read over Create Index.[quote][quote]btw, that's a rather odd predicate on the date column...[/quote]how can you ellaborate ?[/quote][quote]SubmitDate&amp;gt;=' ' and SubmitDate&amp;lt;' '[/quote]There is no possible way that any date can be both greater than or equal to '' and less than ''. Let me rephrase that into numbers...WHERE SomeNumber &amp;gt;=0 AND SomeNumber &amp;lt; 0That's completely, logically impossible as it is only true for a number that's both positive and negative at the same time, which no number is.Either you mis-typed when you copied the query over, or there's some serious flawed logic at work.</description><pubDate>Fri, 18 Jan 2013 03:00:12 GMT</pubDate><dc:creator>GilaMonster</dc:creator></item><item><title>RE: How to set index for these select queries</title><link>http://www.sqlservercentral.com/Forums/Topic1408195-1292-1.aspx</link><description>[quote][b]GilaMonster (1/17/2013)[/b][hr]Index on (IsDeleted, SubmitDate DESC) include (ProdName,Category,TotalStock,Price)[/quote]What would be the exact sql query to create the index.[quote]btw, that's a rather odd predicate on the date column...[/quote]how can you ellaborate ?</description><pubDate>Thu, 17 Jan 2013 21:28:59 GMT</pubDate><dc:creator>prakash.kumar3669</dc:creator></item><item><title>RE: How to set index for these select queries</title><link>http://www.sqlservercentral.com/Forums/Topic1408195-1292-1.aspx</link><description>Index on (IsDeleted, SubmitDate DESC) include (ProdName,Category,TotalStock,Price)btw, that's a rather odd predicate on the date column...</description><pubDate>Thu, 17 Jan 2013 06:39:09 GMT</pubDate><dc:creator>GilaMonster</dc:creator></item><item><title>RE: How to set index for these select queries</title><link>http://www.sqlservercentral.com/Forums/Topic1408195-1292-1.aspx</link><description>[quote]For better solution.post that Query[/quote]select ProdName,Category,TotalStock,Price from Product where SubmitDate&amp;gt;=' ' and SubmitDate&amp;lt;' ' and IsDeleted=0 order by SubmitDate Desc</description><pubDate>Thu, 17 Jan 2013 05:12:12 GMT</pubDate><dc:creator>prakash.kumar3669</dc:creator></item><item><title>RE: How to set index for these select queries</title><link>http://www.sqlservercentral.com/Forums/Topic1408195-1292-1.aspx</link><description>[quote][b]prakash.kumar3669 (1/17/2013)[/b][hr]What i have read from online articles, its important to index the columns which comes in where condition.[/quote] Not only Where BUT group by, order by , JOIN's ON clause , Partititon by , and also the SELECT's columns. See this [url]http://www.sqlservercentral.com/articles/Indexing/68439/[/url][quote][b]prakash.kumar3669 (1/17/2013)[/b][hr]if i have 5 columns to retrieve in my queries then what's the best way of indexing ?[/quote] then those columns should be part of Covering index INCLUDE's part. For better solution.post that Query</description><pubDate>Thu, 17 Jan 2013 04:30:21 GMT</pubDate><dc:creator>Bhuvnesh</dc:creator></item><item><title>RE: How to set index for these select queries</title><link>http://www.sqlservercentral.com/Forums/Topic1408195-1292-1.aspx</link><description>[quote]Why not?[/quote]I don't know, i have no experience of implementing indexing till now. What i have read from online articles, its important to index the columns which comes in where condition. if i have 5 columns to retrieve in my queries then what's the best way of indexing ?</description><pubDate>Thu, 17 Jan 2013 04:23:33 GMT</pubDate><dc:creator>prakash.kumar3669</dc:creator></item><item><title>RE: How to set index for these select queries</title><link>http://www.sqlservercentral.com/Forums/Topic1408195-1292-1.aspx</link><description>[quote][b]prakash.kumar3669 (1/17/2013)[/b][hr]in other words covering queries in not an option i guess.[/quote]Why not?</description><pubDate>Thu, 17 Jan 2013 03:19:43 GMT</pubDate><dc:creator>GilaMonster</dc:creator></item><item><title>RE: How to set index for these select queries</title><link>http://www.sqlservercentral.com/Forums/Topic1408195-1292-1.aspx</link><description>[quote]Do you always require "SELECT *" in your every query ?[/quote]the number of columns i need to display is 6-7 so i have put on * for the reference, in other words covering queries in not an option i guess.</description><pubDate>Thu, 17 Jan 2013 01:55:28 GMT</pubDate><dc:creator>prakash.kumar3669</dc:creator></item><item><title>RE: How to set index for these select queries</title><link>http://www.sqlservercentral.com/Forums/Topic1408195-1292-1.aspx</link><description>[quote][b]prakash.kumar3669 (1/17/2013)[/b][hr]In my table (large one) there is mainly three select queries:1) select * from Product where productid=101Here productid is primary key so it is clustered index, so no problem here.2) select * from Product where IsDeleted=0 order by SubmitDate Desc3) select * from Product where SubmitDate&amp;gt;=' ' and SubmitDate&amp;lt;' ' and  IsDeleted=0 order by SubmitDate Descfor 2) and 3) IsDeleted is a bit type contains duplicate values, and SubmitDate is datetime contains duplicate values.How to set index for 2) and 3)[/quote] Do you always require "SELECT *" in your every query ?</description><pubDate>Thu, 17 Jan 2013 01:26:55 GMT</pubDate><dc:creator>Bhuvnesh</dc:creator></item><item><title>RE: How to set index for these select queries</title><link>http://www.sqlservercentral.com/Forums/Topic1408195-1292-1.aspx</link><description>Index on IsDeleted, SubmitDate DESCProbably won't be used unless there's a small number of rows that qualify or you can get rid of that SELECT * , retrieve only the columns required and make the index covering.</description><pubDate>Thu, 17 Jan 2013 01:19:21 GMT</pubDate><dc:creator>GilaMonster</dc:creator></item><item><title>How to set index for these select queries</title><link>http://www.sqlservercentral.com/Forums/Topic1408195-1292-1.aspx</link><description>In my table (large one) there is mainly three select queries:1) select * from Product where productid=101Here productid is primary key so it is clustered index, so no problem here.2) select * from Product where IsDeleted=0 order by SubmitDate Desc3) select * from Product where SubmitDate&amp;gt;=' ' and SubmitDate&amp;lt;' ' and  IsDeleted=0 order by SubmitDate Descfor 2) and 3) IsDeleted is a bit type contains duplicate values, and SubmitDate is datetime contains duplicate values.How to set index for 2) and 3)</description><pubDate>Thu, 17 Jan 2013 01:06:48 GMT</pubDate><dc:creator>prakash.kumar3669</dc:creator></item></channel></rss>