Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SQL Index question

Status
Not open for further replies.

jepatte

Programmer
Jul 4, 2005
75
US
I have a table with 2.5 million records. One field either has Y or N in it. Do I need to create an index on this field if I want to query on it. If I don't, it usually take 20 or 30 seconds to return results. The thing is that I have a lot of fields like this. If I do this for all these fields, do I have too many indexes?
 
Indexing these fields will not get you much. When a column has only two values, when SQL goes to query the column, it has to scan the index, which is only moderetly better than scanning the table.

Unless you are running a report off of this column, it's not going to be the best column to filter off of.

Denny
MCSA (2003) / MCDBA (SQL 2000)
MCTS (SQL 2005 / Microsoft Windows SharePoint Services 3.0: Configuration / Microsoft Office SharePoint Server 2007: Configuration)
MCITP Database Administrator (SQL 2005) / Database Developer (SQL 2005)

--Anything is possible. All it takes is a little research. (Me)
[noevil]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top