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)
 Building queries ...

Author  Topic 

Karander
Starting Member

34 Posts

Posted - 2006-10-01 : 11:44:32
Hi,

I have several questions which concern bulding fast sql query ...

1) If i haev several tables. I join them 6 - times, these tables
are very huge, mln records each. What is the best approach to query
them. I know this is a general question, but I would like to know
what is best method to start writing query, what should i take
a note of sth for ?

2) I have thought, that if I limit records from one table and then
i will join this table to rest of them, i will have better
efficiency ..
and i wrote sth like this:

select sth from table1
join table2 on ..
join table3 on ..

join (select sth2 S from table
where S = PARAM
) S on ....
where ...

and theoretically this query is executed fast, but the problem was
when i wanted to place this select in external update select ..
and write sth liks this:

update T set field1 = (
select sth from table1
join table2 on ..
join table3 on ..

join (select sth2 S from table
where S = T.PARAM
) S on ....
where ...
) from table T

and the problem is that mssql doesn't see T.PARAM and probable
there is not workaround. Anyway I have constructed this query
joining subquery to have more efficiency... how could i this
update query subsititute for another working one ...

3. what is different in performance between joing tables or writing
subqueries

4. Any tutorial, article, query building will be very appreciated

Thanks :)









Page47
Master Smack Fu Yak Hacker

2878 Posts

Posted - 2006-10-02 : 08:35:15
Craig Freedman has written some very good blogs about how the compiler handles different joins. Look at http://blogs.msdn.com/craigfr/archive/category/14122.aspx.

Jay White
Go to Top of Page
   

- Advertisement -