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
 General SQL Server Forums
 New to SQL Server Programming
 Help me to make procedure more Fast

Author  Topic 

vedjha
Posting Yak Master

228 Posts

Posted - 2009-11-27 : 22:10:38
Hello sir,

I have a procedure, which takes approx 1 hrs to execute. I have to run this procedure on web. so it must take less to less time on web


procedure:
~~~~~~~~~~~~~


WITH CatTree (vaid, vspID,cplacement,vunderspon,vunderplacement,Level)
AS
(

SELECT vaID, vspID,cplacement,vunderspon,vunderplacement, 1 As [Level]
FROM members
WHERE vspid='M116913' and cplacement='R'


UNION ALL

SELECT C.vaid, C.vspID,C.cplacement,C.vunderspon,C.vunderplacement, Level + 1
FROM members C
INNER JOIN CatTree ON
((CatTree.vaid= C.vspid) or (CatTree.vaid= C.vunderspon))



)
SELECT * FROM CatTree


=================================================

I have approx 1.5 Lakh Data. starting ID takes more time.

Help me to make it more fast


Ved

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-11-27 : 22:12:34
what are indexes you've on current table?
Go to Top of Page

vedjha
Posting Yak Master

228 Posts

Posted - 2009-11-27 : 22:40:41
vaid column

Ved
Go to Top of Page

vedjha
Posting Yak Master

228 Posts

Posted - 2009-11-27 : 22:41:46
I am giving u mu case study
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~




spill-> Reffered ID

Hello Sir ,

I have to find Downline details of User such as

UserID Placement Sponsor UnderPlacement Reffered

M2 L M1
M3 R M1
M4 L M2
M5 R M2
M6 M2 L M4
M7 M1 L M6
M8 M1 L M7


it means
M1->M2
M1->M3
M2->M4
M2->M5
M2->M6
M1->M7
M1->M8

Graphical Image as:
M1
M2 M3
M4 M5
M6
M7
M8


Note: Every user can make(sponsor) infinity no of user . Bt every user having their two hands Left and Right. If user make two user it means his both hand is full. if he wants make(sponsor) more than two user then he will make user under his downline. it will be said as spilling. Users can sponsor or make infinty no of user under his downline.

some question to clearify this example as,

Q) To find Users, Sponsored by M1
Ans.
M1
~~~~

M2
M3
M4
M5
M6
M7
M8

Q) To find Users, Sponsored by M2
Ans.
M2
~~~~
M4
M5
M6
M7
M8

Q) To find Users, Sponsored by M3
Ans. NO USER AVILABLE

Q) To find Users, Sponsored by M4
Ans. SINCE M4 HAS NOT SPONSORED ANY USER, BUT USERS ARE SPONSORED BY M4'S SPONSOR(UPPER USER OF M4) AND COME(SPILL) UNDER M4. SO M4 HAVING 3 USERS AS,
M4
~~~~
M6
M7
M8

Q) To find Users, Sponsored by M5
Ans. NO USER AVILABLE


Q) To find Users, Sponsored by M6
Ans. SINCE M6 HAS NOT SPONSORED ANY USER, BUT USERS ARE SPONSORED BY M6'S SPONSOR(UPPER USER OF M6) AND COME(SPILL) UNDER M6. SO M4 HAVING 2 USERS AS,

M6
~~~~

M7
M8


Q) To find Users, Sponsored by M7
Ans. SINCE M7 HAS NOT SPONSORED ANY USER, BUT USERS ARE SPONSORED BY M7'S SPONSOR(UPPER USER OF M7) AND COME(SPILL) UNDER M7. SO M7 HAVING 1 USERS AS,


M7
~~~~
M8

Q) To find Users, Sponsored by M8
Ans. NO USER AVILABLE



===================================


now my question is, How to find users which is made by M2



Ved
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-11-28 : 01:39:00
sorry i didnt understand how you get
M7
M8
in result for users sponsored by M2?
Go to Top of Page
   

- Advertisement -