HI Guys
While working today with SQL i got one concern:
I have one table tblHierarchy. It has fields: ID, ParentID,externalRef
And this table stores hierarchy upto 6 level (it may vary but not more than 6). This table stores hierarchy for say 20,000 records. Now in my sp, i want to retrieve data from this table using JOIN with externalRef field of tblHierarchy.
My another table is say tblCustom. There is a field say text8 which stores the leaf level of hierarchy for every record in this table.The existing code uses self join with table tblHierarchy, i tried replacing it with CROSS/OUTER APPLY. But the performance of APPLY is very slow. Earlier code was executing in 15-20 secs but now it takes more than 4 mins. So that means APPLY clause gives no performance gain.
Please advice.