@@ -14,7 +14,11 @@ namespace Xtensive.Orm.Providers
1414{
1515 internal sealed class SimpleCommandProcessor : CommandProcessor , ISqlTaskProcessor
1616 {
17- private readonly Queue < SqlTask > tasks ;
17+ // equals to default batch size from SessionConfiguration
18+ // hard to choose particular value so let it be some known number :)
19+ private const int DefaultTaskQueueCapacity = 25 ;
20+
21+ private Queue < SqlTask > tasks = new ( DefaultTaskQueueCapacity ) ;
1822
1923 void ISqlTaskProcessor . ProcessTask ( SqlLoadTask task , CommandProcessorContext context )
2024 {
@@ -51,8 +55,8 @@ void ISqlTaskProcessor.ProcessTask(SqlPersistTask task, CommandProcessorContext
5155
5256 public override void ExecuteTasks ( CommandProcessorContext context )
5357 {
54- context . ProcessingTasks = new Queue < SqlTask > ( tasks ) ;
55- tasks . Clear ( ) ;
58+ context . ProcessingTasks = tasks ;
59+ tasks = new Queue < SqlTask > ( DefaultTaskQueueCapacity ) ;
5660
5761 while ( context . ProcessingTasks . Count > 0 ) {
5862 AllocateCommand ( context ) ;
@@ -79,8 +83,8 @@ public override void ExecuteTasks(CommandProcessorContext context)
7983
8084 public override async Task ExecuteTasksAsync ( CommandProcessorContext context , CancellationToken token )
8185 {
82- context . ProcessingTasks = new Queue < SqlTask > ( tasks ) ;
83- tasks . Clear ( ) ;
86+ context . ProcessingTasks = tasks ;
87+ tasks = new Queue < SqlTask > ( DefaultTaskQueueCapacity ) ;
8488
8589 while ( context . ProcessingTasks . Count > 0 ) {
8690 AllocateCommand ( context ) ;
@@ -152,7 +156,6 @@ private void ValidateCommandParameters(CommandPart commandPart)
152156 public SimpleCommandProcessor ( CommandFactory factory , int maxQueryParameterCount )
153157 : base ( factory , maxQueryParameterCount )
154158 {
155- tasks = new Queue < SqlTask > ( ) ;
156159 }
157160 }
158161}
0 commit comments