Home All Groups Group Topic Archive Search About
Author
9 Feb 2006 9:37 PM
Bac2Day1
Here's my view1:

tbl_1
join_id
record_id
sku_id

tbl_2
sku_id
sku
sku_desc

tbl_3
join_id
sku_id
part_id

tbl_4
part_id
part
part_desc

I've joined
tbl_1.sku_id to tbl_2.sku_id
tbl_2.sku_id to tbl_3.sku_id
tbl_3.part_id to tbl_4.part_id

....Now I've got a sproc:
SELECT part, part_desc FROM view1 WHERE record_id = @Record_Id



My question...  What would be the best indexes to set up for this
senario?  SQL server by default sets up clustered indexes on the
join_id on my join tables...  but I'm not sure if that's the best.
Thanks in advance.

Author
10 Feb 2006 12:54 AM
Louis Davidson
totally depends on the size of your data.  Are you having specific
performance issues that you can see in the query plan?

It really depends on the cardinality of these relationships and how many
rows will be returned.

For the simple answer I would probably suggest that you index all columns
referred to in here:

> tbl_1.sku_id to tbl_2.sku_id
> tbl_2.sku_id to tbl_3.sku_id
> tbl_3.part_id to tbl_4.part_id
>
> ...Now I've got a sproc:
> SELECT part, part_desc FROM view1 WHERE record_id = @Record_Id

But this is not a guarantee that it will help.  Check the query plan and
work on the hotspots that take the most time in the plan.


( I will assume that your names columns designs etc are just for examples,
since they definitely need help if not :)

--
----------------------------------------------------------------------------
Louis Davidson - http://spaces.msn.com/members/drsql/
SQL Server MVP
"Arguments are to be avoided: they are always vulgar and often convincing."
(Oscar Wilde)

Show quoteHide quote
"Bac2Day1" <Bac2D***@gmail.com> wrote in message
news:1139521049.980469.247710@g44g2000cwa.googlegroups.com...
> Here's my view1:
>
> tbl_1
> join_id
> record_id
> sku_id
>
> tbl_2
> sku_id
> sku
> sku_desc
>
> tbl_3
> join_id
> sku_id
> part_id
>
> tbl_4
> part_id
> part
> part_desc
>
> I've joined
> tbl_1.sku_id to tbl_2.sku_id
> tbl_2.sku_id to tbl_3.sku_id
> tbl_3.part_id to tbl_4.part_id
>
> ...Now I've got a sproc:
> SELECT part, part_desc FROM view1 WHERE record_id = @Record_Id
>
>
>
> My question...  What would be the best indexes to set up for this
> senario?  SQL server by default sets up clustered indexes on the
> join_id on my join tables...  but I'm not sure if that's the best.
> Thanks in advance.
>

Bookmark and Share