SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Fun with sp_executeSQL


Fun with sp_executeSQL

Author
Message
Dave Poole
Dave Poole
SSC-Insane
SSC-Insane (24K reputation)SSC-Insane (24K reputation)SSC-Insane (24K reputation)SSC-Insane (24K reputation)SSC-Insane (24K reputation)SSC-Insane (24K reputation)SSC-Insane (24K reputation)SSC-Insane (24K reputation)

Group: General Forum Members
Points: 24253 Visits: 3493
Comments posted to this topic are about the item Fun with sp_executeSQL

LinkedIn Profile
www.simple-talk.com
ChandlerDBA
ChandlerDBA
SSC Rookie
SSC Rookie (39 reputation)SSC Rookie (39 reputation)SSC Rookie (39 reputation)SSC Rookie (39 reputation)SSC Rookie (39 reputation)SSC Rookie (39 reputation)SSC Rookie (39 reputation)SSC Rookie (39 reputation)

Group: General Forum Members
Points: 39 Visits: 15
Excellent evidence-based article. More please. :-)
poojari045
poojari045
SSC Veteran
SSC Veteran (248 reputation)SSC Veteran (248 reputation)SSC Veteran (248 reputation)SSC Veteran (248 reputation)SSC Veteran (248 reputation)SSC Veteran (248 reputation)SSC Veteran (248 reputation)SSC Veteran (248 reputation)

Group: General Forum Members
Points: 248 Visits: 59
Nice article .:-)
Gazareth
Gazareth
SSChampion
SSChampion (11K reputation)SSChampion (11K reputation)SSChampion (11K reputation)SSChampion (11K reputation)SSChampion (11K reputation)SSChampion (11K reputation)SSChampion (11K reputation)SSChampion (11K reputation)

Group: General Forum Members
Points: 11452 Visits: 6068
Thanks David, useful article.
Christoph Muthmann
Christoph Muthmann
Mr or Mrs. 500
Mr or Mrs. 500 (528 reputation)Mr or Mrs. 500 (528 reputation)Mr or Mrs. 500 (528 reputation)Mr or Mrs. 500 (528 reputation)Mr or Mrs. 500 (528 reputation)Mr or Mrs. 500 (528 reputation)Mr or Mrs. 500 (528 reputation)Mr or Mrs. 500 (528 reputation)

Group: General Forum Members
Points: 528 Visits: 323
Nice article, but I'm missing a hint to adhoc queries and their influence on the proc cache. You can save a lot of memory by using the optimize for ad hoc workloads Option.
http://msdn.microsoft.com/en-us/library/cc645587.aspx


For more details see this blog entry from Kimberly Tripp:
http://sqlskills.com/BLOGS/KIMBERLY/post/Procedure-cache-and-optimizing-for-adhoc-workloads.aspx

Have a nice day,
Christoph
Tony++
Tony++
SSCrazy
SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)SSCrazy (2.9K reputation)

Group: General Forum Members
Points: 2934 Visits: 2078
On your point regarding variable length parameters, I've seen Subsonic (ORM) do this behavior too. I figured it what was happening when I started digging into why my proc cache was 6GB. My devs changed their code to call procs (fixed-length parameters) and cut the proc cache down to 2.5GB. Happy day, my data cache hit ratio improved nicely with just a little bit of work.
ganci.mark
ganci.mark
SSCommitted
SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)SSCommitted (1.8K reputation)

Group: General Forum Members
Points: 1813 Visits: 574
Great article David. Thank you.

I thought that there were limits imposed on the various memory components based on on the total amount of memory given to SQL Server.

For example: Proc Cache limits
SQL Server 2005 SP2
75% of server memory from 0-4GB +
10% of server memory from 4Gb-64GB +
5% of server memory > 64GB
So 14GB given to a SQL SERVER 2005 SP2 would yield a 4GB Proc Cache.

Is it correct in stating that the limits do not exist and proc cache for example can consume additional memory?

Thanks
Mark
Dave Poole
Dave Poole
SSC-Insane
SSC-Insane (24K reputation)SSC-Insane (24K reputation)SSC-Insane (24K reputation)SSC-Insane (24K reputation)SSC-Insane (24K reputation)SSC-Insane (24K reputation)SSC-Insane (24K reputation)SSC-Insane (24K reputation)

Group: General Forum Members
Points: 24253 Visits: 3493
Christoph Muthmann (1/31/2012)
Nice article, but I'm missing a hint to adhoc queries and their influence on the proc cache. You can save a lot of memory by using the optimize for ad hoc workloads Option.
http://msdn.microsoft.com/en-us/library/cc645587.aspx



Good catch, wish I'd known this 2 years ago! I've passed this one on to my colleagues.
The worry now is that I'm going to hear "we don't have to fix this because there is a DB option".Crazy

LinkedIn Profile
www.simple-talk.com
Dave Poole
Dave Poole
SSC-Insane
SSC-Insane (24K reputation)SSC-Insane (24K reputation)SSC-Insane (24K reputation)SSC-Insane (24K reputation)SSC-Insane (24K reputation)SSC-Insane (24K reputation)SSC-Insane (24K reputation)SSC-Insane (24K reputation)

Group: General Forum Members
Points: 24253 Visits: 3493
Mark, I haven't come across any predefined limits for proc cache but that doesn't mean to say they aren't there.

Time for further research methinks!

LinkedIn Profile
www.simple-talk.com
chrisfradenburg
chrisfradenburg
SSCarpal Tunnel
SSCarpal Tunnel (4.1K reputation)SSCarpal Tunnel (4.1K reputation)SSCarpal Tunnel (4.1K reputation)SSCarpal Tunnel (4.1K reputation)SSCarpal Tunnel (4.1K reputation)SSCarpal Tunnel (4.1K reputation)SSCarpal Tunnel (4.1K reputation)SSCarpal Tunnel (4.1K reputation)

Group: General Forum Members
Points: 4070 Visits: 2080
David.Poole (1/31/2012)
Christoph Muthmann (1/31/2012)
Nice article, but I'm missing a hint to adhoc queries and their influence on the proc cache. You can save a lot of memory by using the optimize for ad hoc workloads Option.
http://msdn.microsoft.com/en-us/library/cc645587.aspx



Good catch, wish I'd known this 2 years ago! I've passed this one on to my colleagues.
The worry now is that I'm going to hear "we don't have to fix this because there is a DB option".Crazy


The only thing with that is you're still paying the cost to the query optimizer for each new compile. It's just taking less space in memory unless it's called again.

It's worth mentioning that you see the same capitalization behavior if you start using plan guides. It has to do with the fact that a hash of the query is created first and since there's potential for SQL to be capitalization sensitive it doesn't muck with capitalization before doing the hash.
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search