[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

Question
[x]
Attachment Details

SQL Server Index Recommendation

Asked by r_i_x in SQL Server 2005, SQL Server 2008

Tags: SQL Server 2005

Have a transactional table like this (tblTrx):
TableID, int
ProductID, int
CreatedOn, datetime
Quantity, int

Size of table is getting to 2.5M records and will grow at about 1.5M/year.

Most queries are date related wanting to know what the product quantities were at a certain date so we generally query like this:

SELECT * FROM tblTable T
INNER JOIN
(SELECT ProductID, MAX(TableID) AS TableID FROM tblTrx WHERE CreatedOn > @TIMESTAMP GROUP BY ProductID) M
ON T.ProductID = M.ProductID
AND T.TableID = M.TableID

Clustered index is on TableID
Non-clustered index on CreatedOn

So, a couple questions:
1. Is this type of query optimal for getting this data?
2. Thoughts on indexes?

What I'm finding is that a lot of queries are doing Clustered Index Scans rather than Seeks and it's getting slow.

Thoughts?
 
Related Solutions
Keywords: SQL Server Index Recommendation
Title
1 index advice
 
Loading Advertisement...
 
[+][-]11/05/09 05:50 AM, ID: 25749377Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11/05/09 05:51 AM, ID: 25749380Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11/05/09 05:55 AM, ID: 25749420Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]11/05/09 05:57 AM, ID: 25749449Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11/05/09 06:06 AM, ID: 25749529Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20091111-EE-VQP-92 - Hierarchy / EE_QW_3_20080625