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)
 Optimizing the query

Author  Topic 

Ramnadh
Starting Member

23 Posts

Posted - 2004-09-16 : 06:23:23
Hi ,

I have written a query which is having lot of joins with 12 tables.

In that almost 9 tables are always having lesser number of row in it.

But for the other 3 tables there can be 1 lakh records in it.

Problems:

1. When i am joining the tables with more rows it is taking much time.

How do i optimize the joins ?

2. I am using DISTINCT, the number of rows that are resulted are just above 4000.

How do i avoid DISTINCT ? distinct is much needed because we will have same rows more than once because of the tables.

Is there any other workaround to avoid DISTINCT ?

3. I am using an user defined function in which the function uses the 2 tables in the Database to build a concatenated string this uses COALESCE function.

Anyone help me regd. the optimizing the performance of this Query.

Thanx,
Ramnadh

Ramnadh

Amethystium
Aged Yak Warrior

701 Posts

Posted - 2004-09-16 : 06:29:43
Not sure how we can help if we don't know what the query is. Your description is not very clear. Have you tried using a GROUP BY instead of DISTINCT. I don't think it will make a huge difference to be honest but perhaps the bottle neck is occurring elsewhere. Have you run an execution plan for your query?! That should give you a clue.


------------->>> BREAKING NEWS!!! <<<-------------
Saddam Hussien has weapons of mass destrcution
Go to Top of Page
   

- Advertisement -