• codeplexer (1/14/2013)


    I think it does return the ragged hierarchy like your example. It tooks 22ms (definitely less than 1s) to return 72 rows.

    Screeshot here

    http://tinyurl.com/be6yqxp

    or

    https://docs.google.com/file/d/0B8BX62MoYSHGRjd3RWo2Q0pERFU/edit

    That may be true but you are using Adventure works DW as the test case, which is a pre-defined dataset with all the nasty work done for you so that you can consume the data in a nice simple way.

    I'm using a completely different source object that comes from a 3rd party finance system (Oracle Financials) which has different rules and 3nf schema design.

    Also the timings I gave are for building a 3700 row chart of accounts, which means that when you extrapolate out your query by around 50 times your query runs is likely to run in around 1100ms, or lets be generous and apply a 25 times assuming economies of scale its still around 500ms.

    In addition to this I dont have the description on the same table as the Hierachy, and have to Join an additional 2 tables for each node in order to get that piece of information and also identify 'dead' paths, so now your query will have at least least twice the number of joins as present (one for each level in the hierarchy) to look remove dead paths, then you also have to look up the descriptions which is at least one more join if you encapsulate the original query in a CTE, or an additional join for each level.

    I dont state that this is the optimal solution, but it hits and surpasses the NFR requirement (5 minutes) for this piece of code by at least one order of magnitude.

    Given more time and resources (and most importantly desire from those that write my paycheque every month) I would love to rewrite it and get an optimal solution, but at the moment free time during the day is at a premium and the will is lacking from my superiors (if it isnt broken why fix it).

    _________________________________________________________________________
    SSC Guide to Posting and Best Practices