• Patrick Russell (11/7/2008)


    I have some procedures which i consider simple (joining 5 tables) returning mayby 10-12 records/with 3 columns. When I run the app, and it accesses this particular procedure it takes about 8 - 10 seconds to return the data. Testing, I ran the same procedure in the SQL Analyzer and it also took about 8 -10 seconds. I then ran it using the select statement in the procedure and it returned in less then a second. To confirm, I gave the db user select rights to the tables in question then changed the app to pass a select string instead of a stored procedure and again it returned in less then a second.

    Sounds like parameter sniffing. Can you post the code of the procedure?

    For some more info on parameter sniffing, see -

    http://sqlinthewild.co.za/index.php/2007/11/27/parameter-sniffing/

    http://sqlinthewild.co.za/index.php/2008/02/25/parameter-sniffing-pt-2/

    http://sqlinthewild.co.za/index.php/2008/05/22/parameter-sniffing-pt-3/

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass