• tony28 (10/17/2013)


    Lynn Pettis (10/17/2013)


    tony28 (10/17/2013)


    Before than i will give the design and data,

    I forgot for I think important issue, If this function is using for example inside 20procedures, it can causes this problem? For example lock or something ?

    Because I created new one and without relation in another procedures and this is 2ms... BUT like I wrote above, if I will started this function two times in same time, the second will be 2ms, but first 25ms.

    I will try on the break time delete execution plan.

    txh for reply

    What you are experiencing with the first run being slower than the second is caused be caching. The first run, the data has to pulled from disk to memory. the second time the data is already there.

    What we are telling you is that the function you have written can be improved. You just have to provide us with the DDL (CREATE TABLE) statements for the tables used by the function, sample data (as INSERT INTO statements) for those tables, and the expected results based on given inputs to the function and the given sample data.

    Yes i know about it, that if i will delete ex.plan, I have to check second run, but I think if I do like this

    select * from FN_TABLE_GET_WORK_DATE() NOLOCK

    select * from FN_TABLE_GET_WORK_DATE() NOLOCK

    Ok I will do DDL. But I think that problem can be, that this function use about 20procedures

    The more procedures that use this function, the more important it is to make sure it is as efficient as possible.

    I would also stay away from using the NOLOCK hint as it could introduce errors into the numerous procedures that use the function.