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.
| Author |
Topic |
|
meef
Posting Yak Master
113 Posts |
Posted - 2011-09-26 : 14:53:13
|
I'll use this FROM section as an example:FROM tbl_bol tb LEFT JOIN dbo.tbl_ref_nums u on tb.bol_id = u.bol_id INNER JOIN dbo.tbl_214_datatable p on tb.bol_id = p.bol_id INNER JOIN tbl_carrier c ON c.scac_code = p.scac INNER JOIN tbl_carrier_access a ON a.carrier_id = c.carrier_id AND a.dba_id = tb.dba_id I think you're supposed to index on the columns that you are matching to, not the ones you're joining from, is that correct? Does that mean index on columns after the "ON" portion? |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2011-09-26 : 14:58:45
|
| usually you create index on joining columns. didnt understand what you're asking actually------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
meef
Posting Yak Master
113 Posts |
Posted - 2011-09-26 : 14:59:50
|
| Going by the sample I posted above, can you tell which ones would need to be indexed?EDIT: I was guessing these are the ones to index on:bol_idscac_codecarrier_iddba_id |
 |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
|
GilaMonster
Master Smack Fu Yak Hacker
4507 Posts |
Posted - 2011-09-26 : 16:28:50
|
| For the table p, you probably want a composite index either (bol_id, scac) or (scac, bol_id). Test to see which works better. Or add bothFor the table c, either (scac_code, carrier_id) or (carrier_id, scac_code). Same as above.Same thing with tb--Gail ShawSQL Server MVP |
 |
|
|
Kristen
Test
22859 Posts |
Posted - 2011-09-26 : 17:48:54
|
| Might want some INCLUDE columns to in order to "cover" other columns used in the query - SELECT columns, etc. |
 |
|
|
|
|
|
|
|