Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Query Performance

Author  Topic 

Ramnadh
Starting Member

23 Posts

Posted - 2004-09-18 : 23:29:09
Hi

There are two tables TableA and TableB , where TableA consists of 100,000 rows and TableB consits of 60,000 rows.

In the TableA Id is the Primary Key (Clustered Index) and in the TableB MessageId is the Foreign Key for TableA (Id), which is a non-Clustered Index.

When i Write a query by joining two tables which will give the rows that satisfies some condition.

Ex: SELECT TableA.Id FROM TableA
INNER JOIN TableA.Id = TableB.MessageId
WHERE TableB.ResourceId = 12

This is taking more than a second to retrieve 1200 rows to get the matching Ids with the specified criteria.

Cannot we decrease efficiency of the query ? what are the other options so that the query performance is decreased.

Ramnadh

Kristen
Test

22859 Posts

Posted - 2004-09-19 : 01:38:02
Is the time actually taken up retrieving the 1,200 rows to the client?

How long does this take:

SELECT COUNT(*)
FROM
(
SELECT TableA.Id FROM TableA
INNER JOIN TableA.Id = TableB.MessageId
WHERE TableB.ResourceId = 12
) X

Kristen
Go to Top of Page
   

- Advertisement -