| |
|
If this is your first visit, be sure to check out the FAQ by clicking the link above.
You may have to register before you can post: click the register link above to proceed.
To start viewing messages, select the forum that you want to visit from the selection below.
|
 |
|

11-03-09, 02:28
|
|
Registered User
|
|
Join Date: Sep 2009
Posts: 16
|
|
|
put all columns in one index or create one index per column
|
|
Hi,
For reach best performance, its better to put all columns in one index or create one index per column that must have index ?
|
|

11-03-09, 04:10
|
|
King of Understatement
|
|
Join Date: Feb 2004
Location: One Flump in One Place
Posts: 14,905
|
|
Farax x - probably neither.
It sounds like you don't know too much about indexes but have heard that having some "speeds things up". it is also true that having some indexes can "slow things down".
I would either read up on indexing in SQL Server, or run all you queries against your database and then run the Database Tuning Advisor to find out what queries are recommended. The former is the better plan, the latter is quick, dirty and cheap but won't give you an optimal set up.
__________________
Testimonial:
Quote:
pootle flump
ur codings are working excelent.
|
|
|

11-03-09, 05:07
|
|
Registered User
|
|
Join Date: Aug 2009
Posts: 262
|
|
|
|
None of above / both / one of above.
depending upon your table structure , data , NOT NUMBER OF ROWS, relation , dml .
best performance comes with no index in sql-server ( unlinke oracle)
and when needed adding up an index to the column as per required by the query .
but now you have an option of index-referencing in select statement . This gives you a robust option to index your query according to your specification.
|
|

11-03-09, 07:52
|
|
Registered User
|
|
Join Date: Sep 2009
Posts: 16
|
|
thanx alot for your answer
Quote:
Originally Posted by mishaalsy
None of above / both / one of above.
depending upon your table structure , data , NOT NUMBER OF ROWS, relation , dml .
best performance comes with no index in sql-server ( unlinke oracle)
and when needed adding up an index to the column as per required by the query .
but now you have an option of index-referencing in select statement . This gives you a robust option to index your query according to your specification.
|
|
|

11-03-09, 09:31
|
|
www.gvee.co.uk
|
|
Join Date: Jan 2007
Location: UK
Posts: 10,002
|
|
Quote:
Originally Posted by mishaalsy
best performance comes with no index in sql-server
|
Come again?
|
|

11-03-09, 09:52
|
|
World Class Flame Warrior
|
|
Join Date: Jun 2003
Location: Ohio
Posts: 11,556
|
|
Quote:
Originally Posted by gvee
Quote:
Originally Posted by mishaalsy
best performance comes with no index in sql-server
|
Come again?
|
He said the best performance comes with no index in sql-server.
Wait...what?
__________________
If it's not practically useful, then it's practically useless.
blindman
www.chess.com: "sqlblindman"
|
|

11-03-09, 09:54
|
|
World Class Flame Warrior
|
|
Join Date: Jun 2003
Location: Ohio
Posts: 11,556
|
|
Quote:
Originally Posted by farax_x
Hi,
For reach best performance, its better to put all columns in one index or create one index per column that must have index ?
|
Depends on how you are going to search your data.
If you are going to join or filter on one column at a time, create separate indexes.
If you are usually going to join or filter on multiple columns (often the case if you are using natural keys rather than surrogates), then use a composite index.
__________________
If it's not practically useful, then it's practically useless.
blindman
www.chess.com: "sqlblindman"
|
|

11-03-09, 09:57
|
|
King of Understatement
|
|
Join Date: Feb 2004
Location: One Flump in One Place
Posts: 14,905
|
|
...but the nature of those joins and the nature of those filters, as well as the nature of the data, are also considerations on whether or not you index those columns. There is also the whole clustered Vs nonclustered issue.
I think the OP is of too much an uninformed mind to really be able to make much of that advice.
And I couldn't make sense of much mishaalsy said
__________________
Testimonial:
Quote:
pootle flump
ur codings are working excelent.
|
|
|

11-03-09, 10:25
|
|
SQLTeam Scrub
|
|
Join Date: Nov 2002
Location: Jersey
Posts: 9,984
|
|
Index Intercourse....ummm...intersection!!!
|
|

11-03-09, 11:19
|
|
Registered User
|
|
Join Date: Sep 2009
Posts: 16
|
|
Quote:
Originally Posted by pootle flump
Farax x - probably neither.
It sounds like you don't know too much about indexes but have heard that having some "speeds things up". it is also true that having some indexes can "slow things down".
I would either read up on indexing in SQL Server, or run all you queries against your database and then run the Database Tuning Advisor to find out what queries are recommended. The former is the better plan, the latter is quick, dirty and cheap but won't give you an optimal set up.
|
sorry, may be i explain my question badly.I have a table with 10 million records, and i created Separate index for each index-needed columns . my question is :
its better put all columns together in one index or this situation is the best.
|
|

11-03-09, 11:23
|
|
King of Understatement
|
|
Join Date: Feb 2004
Location: One Flump in One Place
Posts: 14,905
|
|
Again, it depends. I'm afraid there is no "oh it's best to have them all in one column" or "it's best to have them all in different columns".
Indexing is difficult if you don't know a great deal about it but easy when you do. You would be best to read the BoL entries on indexing and then try asking something more specific.
__________________
Testimonial:
Quote:
pootle flump
ur codings are working excelent.
|
|
|

11-03-09, 11:37
|
|
Registered User
|
|
Join Date: Sep 2009
Posts: 16
|
|
Quote:
Originally Posted by pootle flump
Again, it depends. I'm afraid there is no "oh it's best to have them all in one column" or "it's best to have them all in different columns".
Indexing is difficult if you don't know a great deal about it but easy when you do. You would be best to read the BoL entries on indexing and then try asking something more specific.
|
can u tell me, when should put several column in one index ?
|
|

11-03-09, 11:38
|
|
SQLTeam Scrub
|
|
Join Date: Nov 2002
Location: Jersey
Posts: 9,984
|
|
Want to post the DDL and some sample queries you are using?
|
|

11-03-09, 13:13
|
|
World Class Flame Warrior
|
|
Join Date: Jun 2003
Location: Ohio
Posts: 11,556
|
|
Quote:
Originally Posted by farax_x
can u tell me, when should put several column in one index ?
|
Uhm....I already did. Read my post.
__________________
If it's not practically useful, then it's practically useless.
blindman
www.chess.com: "sqlblindman"
|
|

11-03-09, 14:04
|
|
SQLTeam Scrub
|
|
Join Date: Nov 2002
Location: Jersey
Posts: 9,984
|
|
OK, besides all the fun and games...
Understand 1 thing
Only the 1st column will make the optimizer decide what index to use
So, putting all the columns in an index, lets say from a phonebook table is useless, if the list of columns are phone_num, Last_name, first_name, ect
AND you were looking up by last name
it would NEVER use that index and would scan...it MIGHT scan the index depending on the number of columns in your select vs. the columns in the table, vs. the columns in the index
So you see....we need to know what the barrel of data is, and how you want to go after it
There's some exotic stuff like merry-go-round scans...but don't think about
The Index Intersection thing however might be beneficial
But you can do some reading
Understanding SQL Server Indexing
SQL Server Index Basics
General Tips on Optimizing SQL Server Indexes
SQL Server Indexes: The Basics - SQLTeam.com
|
|
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|