Monday, March 12, 2012

indexing

Hi,
There is a table which I regularly run a select query on.
The select query always has a fixed where clause on only three of the columns with different parameters.

This is a query that runs each time:

select * from tblData
where
PersonNo = 2 and EmployeeType = 4 and DataDate = getdate()

This are the types of indexes the table currently has:
One index for each of these three fields
i.e. index1 for PersonNo
index2 for EmployeeType
index3 for DataDate
In addition to the above, I also have created a covering index as follows
index4 for PersonNo,EmployeeType,DataDate

Is what I have enough for indexes on this table please?
Is there anything else I have to do on indexing this table?
Thanks

Indexing is a big subject. At a base level, you should index those columns that will be queried most often, in the order that they are most often queried. That being said, there's a lot more to learn. Here's some beginning info, which has pointers to more advanced concepts:

http://www.informit.com/guides/content.asp?g=sqlserver&seqNum=200&rl=1

|||I am baffled by the DataDate = getdate(); I am surprised that this works; is this just something you meant generically or are you really searching like this?

No comments:

Post a Comment