Stored Procs vs Ad Hoc

  • SQL Kiwi (11/6/2011)


    Gianluca Sartori (10/27/2011)


    GilaMonster (10/27/2011)


    Gianluca Sartori (10/27/2011)


    Vishal.Gajjar (10/27/2011)


    Adhoc queries need to be exactly same for reuse. i.e. case-sensitivity, white spaces, etc...

    True indeed, except for whitespaces.

    Actually he's completely right. The plan cache key for ad-hoc queries is a hash of the query text. It's case-sensitive, white-space sensitive, will change for different parameter values (unless query is simple or forced parameterisation)

    I remember I read somewhere that it didn't consider white-spaces, but I must be wrong, obviously.

    You're thinking of plan guide matching. See the section "Plan Guide Matching Requirements" in sp_create_plan_guide.

    That's it Paul!!!

    I still have confused the two, but at least I'm happy it wasn't my fantasy playing tricks on me. 🙂

    -- Gianluca Sartori

  • Gianluca Sartori (11/7/2011)


    That's it Paul!!!

    I still have confused the two, but at least I'm happy it wasn't my fantasy playing tricks on me. 🙂

    It is inconsistent, so I doubt you are the first, or will be the last, to be caught out by it.

Viewing 2 posts - 16 through 16 (of 16 total)

You must be logged in to reply to this topic. Login to reply