how to improve performance of 'LEFT JOIN'
- From: "lelandhuang@xxxxxxxxx" <lelandhuang@xxxxxxxxx>
- Date: 17 May 2006 23:37:03 -0700
I am developing reporting service and using lots of 'LEFT OUTER JOIN',
I am worried about the performance and want to use some subquery to
improve
the performance.
Could I do that like below,
[the origin source]
SELECT *
FROM TableA
LEFT OUTER JOIN TableB
ON TableA.item1 = TableB.item1
WHERE TableA.item2 = 'xxxx'
TableB.item2 > yyyy AND TableB.item2 < zzzz
I add the subquery to query every table before 'LEFT JOIN'
--------------------------------------------------------------------------
SELECT *
FROM
(SELECT *
FROM TableA
WHERE TableA.item2 = 'xxxx'
) TableC
LEFT OUTER JOIN
(SELECT *
FROM TableB
WHERE TableB.item2 > yyyy AND TableB.item2 < zzzz
) TableD
ON TableC.item1 = TableD.item1
WHERE TableC.item2 = 'xxxx'
TableD.item2 > yyyy AND TableD.item2 < zzzz
--------------------------------------------------------------------------
Can anyone give me some suggestion?
Thanks a lot.
Leland Huang
.
- Follow-Ups:
- Re: how to improve performance of 'LEFT JOIN'
- From: Erland Sommarskog
- Re: how to improve performance of 'LEFT JOIN'
- From: Tom Moreau
- Re: how to improve performance of 'LEFT JOIN'
- Prev by Date: Re: SELECT and regular expression
- Next by Date: Re: Your Professional Advice Please - Design
- Previous by thread: Re: Need a So-Called SSN Encryption
- Next by thread: Re: how to improve performance of 'LEFT JOIN'
- Index(es):
Relevant Pages
|