Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Index Vs Select criteria sequence Expand / Collapse
Author
Message
Posted Tuesday, September 23, 2008 7:18 AM


SSC Eights!

SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!

Group: General Forum Members
Last Login: Monday, June 21, 2010 5:29 AM
Points: 920, Visits: 470
Dear All,

Can any one tell me the relation between the index fields and the query criteria sequence.

I have created the index for all the fields in the database individually.

If I am querying the database with by specifying two fields in the criteria field.

What will happen, will the performance is increased or not?

Kindly give me your suggestion.

Thanks a lot in advance. :)



Nothing is impossible with Hard Work:)
Post #574303
Posted Tuesday, September 23, 2008 7:43 AM
Hall of Fame

Hall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of Fame

Group: General Forum Members
Last Login: Today @ 7:21 AM
Points: 3,821, Visits: 1,085
If your join condition matches with the index fields the query will also performs faster.

It is not the index that imporve the performance. You should look out at defragmentation aslo. If the fragmentation is at the highest level the query also improves.




Post #574333
Posted Tuesday, September 23, 2008 8:50 AM


SSC-Dedicated

SSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-Dedicated

Group: Administrators
Last Login: Today @ 12:34 PM
Points: 31,181, Visits: 15,626
You should not index ALL the fields. That will slow down your updates/inserts/deletes.

You want to include indexes on those fields which are mostly used for queries. If you have two items in the WHERE clause, it depends. You can include both fields in the index, you can have separate indexes that might be used.

Best bet is to get the execution plans for those queries often run and look to see if you are getting index seeks.







Follow me on Twitter: @way0utwest

Forum Etiquette: How to post data/code on a forum to get the best help
Post #574454
Posted Tuesday, September 23, 2008 8:54 AM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Today @ 2:53 PM
Points: 10,277, Visits: 13,257
It depends. What other columns are being returned by the query? What is the selectivity of the column(s) in the index?

As a rule you should not place a separate single column index on every column in a table. It creates more overhead than it is worth. You need to analyze the queries of the database and then index appropriately. A single composite index will likely be better (more selective) than 2 single column indexes and will reduce IO's. FOr example a person search on last name and first name will be faster if the index is a composite index including the last name and first name columns than 2 indexes on last name and first name.




Jack Corbett

Applications Developer

Don't let the good be the enemy of the best. -- Paul Fleming

Check out these links on how to get faster and more accurate answers:
Forum Etiquette: How to post data/code on a forum to get the best help
Need an Answer? Actually, No ... You Need a Question
How to Post Performance Problems
Crosstabs and Pivots or How to turn rows into columns Part 1
Crosstabs and Pivots or How to turn rows into columns Part 2
Post #574468
Posted Tuesday, September 23, 2008 9:46 PM


SSC Eights!

SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!

Group: General Forum Members
Last Login: Monday, June 21, 2010 5:29 AM
Points: 920, Visits: 470
Dear All,

Thanks for you replies.

I have the table which contains some properties of the document in my knowledge repository.

The user can search by specifying any values to the properties.

Based on the values in the properties the where criteria is framed and then I am sending this to the stored procedure.

In the stored procedure I am framing the dynamic query with the where clause with the input where clause.

The table has minimum more than 200000 documents.

So I don't know how to make the index.

I had a discussion and some were saying that I can have index for all the fields.

Can any one tell me how to resolve this?

Thanks a lot.


Nothing is impossible with Hard Work:)
Post #574879
Posted Wednesday, September 24, 2008 1:08 AM


SSC-Forever

SSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-Forever

Group: General Forum Members
Last Login: Today @ 2:09 PM
Points: 40,193, Visits: 36,597
Can you post the proc, the table and the index defs? Are there certain columns that will be more frequently searched than others?


Gail Shaw
Microsoft Certified Master: SQL Server 2008, MVP
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

We walk in the dark places no others will enter
We stand on the bridge and no one may pass

Post #574930
Posted Wednesday, September 24, 2008 4:50 AM


UDP Broadcaster

UDP BroadcasterUDP BroadcasterUDP BroadcasterUDP BroadcasterUDP BroadcasterUDP BroadcasterUDP BroadcasterUDP Broadcaster

Group: General Forum Members
Last Login: Thursday, October 9, 2014 2:26 AM
Points: 1,475, Visits: 1,639
Jaya Chitra (9/23/2008)
Dear All,

Thanks for you replies.

I have the table which contains some properties of the document in my knowledge repository.

The user can search by specifying any values to the properties.

Based on the values in the properties the where criteria is framed and then I am sending this to the stored procedure.

In the stored procedure I am framing the dynamic query with the where clause with the input where clause.

The table has minimum more than 200000 documents.

So I don't know how to make the index.

I had a discussion and some were saying that I can have index for all the fields.

Can any one tell me how to resolve this?

Thanks a lot.


Study the clustered,nonclustered and covering indexes in BOL....
Making a clustered index on the columns in where clause will improve performance


Regards,
Sqlfrenzy

Post #575029
Posted Wednesday, September 24, 2008 4:50 AM


UDP Broadcaster

UDP BroadcasterUDP BroadcasterUDP BroadcasterUDP BroadcasterUDP BroadcasterUDP BroadcasterUDP BroadcasterUDP Broadcaster

Group: General Forum Members
Last Login: Thursday, October 9, 2014 2:26 AM
Points: 1,475, Visits: 1,639
Jaya Chitra (9/23/2008)
Dear All,

Thanks for you replies.

I have the table which contains some properties of the document in my knowledge repository.

The user can search by specifying any values to the properties.

Based on the values in the properties the where criteria is framed and then I am sending this to the stored procedure.

In the stored procedure I am framing the dynamic query with the where clause with the input where clause.

The table has minimum more than 200000 documents.

So I don't know how to make the index.

I had a discussion and some were saying that I can have index for all the fields.

Can any one tell me how to resolve this?

Thanks a lot.


Study the clustered,nonclustered and covering indexes in BOL....
Making a clustered index on the columns in where clause will improve performance


Regards,
Sqlfrenzy

Post #575030
Posted Tuesday, February 9, 2010 11:14 AM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Wednesday, September 17, 2014 1:02 PM
Points: 120, Visits: 296
I would stick with the Design Guidelines for using clustered/non clustered indexes that appears on MSDN. It should give a pretty good idea as to where and what kind of index you might want to use.
Post #862619
Posted Tuesday, February 9, 2010 11:21 AM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Wednesday, September 17, 2014 1:02 PM
Points: 120, Visits: 296
I was just curious about the columns that you might have in there! Could you provide us some detail about that (It would be great for me since I am new to this field and exploring things )
Post #862624
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse