-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: How do I specify sql parameter lengths?
PostPosted: Fri Feb 27, 2009 5:42 am 
Newbie

Joined: Fri Feb 27, 2009 4:24 am
Posts: 1
I've got a loop which updates thousands of objects with information retrieved from external sources. Sql Profiler shows that sp_executesql is executed with the same parameterized query, but the parameter definition list varies. This causes Sql Server to create a new execution plan, and I quickly get thousands of cached execution plans.

Information from SQL Profiler:
exec sp_executesql N'UPDATE Works SET LocalId = @p0, WorkId = @p1, Created = @p2, PublishedYear = @p3, Title = @p4, UniformTitle = @p5, Serie = @p6, Language = @p7, FullTextField = @p8, MarcXml = @p9, Catalog = @p10, MediaType = @p11 WHERE Id = @p12',N'@p0 int,@p1 uniqueidentifier,@p2 datetime,@p3 int,@p4 nvarchar(11),@p5 nvarchar(4000),@p6 nvarchar(13),@p7 nvarchar(3),@p8 nvarchar(2),@p9 nvarchar(3082),@p10 uniqueidentifier,@p11 uniqueidentifier,@p12 uniqueidentifier', ...

exec sp_executesql N'UPDATE Works SET LocalId = @p0, WorkId = @p1, Created = @p2, PublishedYear = @p3, Title = @p4, UniformTitle = @p5, Serie = @p6, Language = @p7, FullTextField = @p8, MarcXml = @p9, Catalog = @p10, MediaType = @p11 WHERE Id = @p12',N'@p0 int,@p1 uniqueidentifier,@p2 datetime,@p3 int,@p4 nvarchar(31),@p5 nvarchar(4000),@p6 nvarchar(32),@p7 nvarchar(3),@p8 nvarchar(2),@p9 nvarchar(1740),@p10 uniqueidentifier,@p11 uniqueidentifier,@p12 uniqueidentifier', ...

These parameters, and some of the others, varies between every call, causing thousands of execution plans to be created and cached.

I've done some research and looked at the GenerateCommand/InitializeParameter methods in the Driver class, and the possibility to override these, but I do not know how I would read the current mappings and update the parameter information. What's the best way to solve this?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.