在空表

时间:2015-06-29 15:33:47

标签: sql-server hibernate join

我们已经体验过SQL Server中一个有趣的错误,我想向您介绍一下。我希望找出它是否真的是一个错误,如果是这样,我可以找到更多有关它的信息。如果它不是一个bug,我希望有人可以向我解释为什么它不是,我们在不知不觉中做错了什么。我似乎无法找到类似问题的描述,我不确定是否应该向Microsoft报告错误或什么。我将首先简要描述问题并提供详细信息。

简而言之,问题似乎是SQL Server在包含许多连接的语句上发生阻塞,当一些(大的?)部分(对不起,这里的数字方面可能更具体)被加入的表是空。通过阻塞,我的意思是它在查询时搅拌并搅拌,从不完成,这导致SQL Server完全停止响应。实际上,运行查询一次会导致CPU跳转到25%并保持不变。另一次尝试和CPU跃升至50%。有时,CPU会达到75%或100%,但在50%的标记下,您甚至无法再登录数据库服务器。

问题发生在我们使用Hibernate(通过Coldfusion ORM)的应用程序中,并且有一个实体(Document)被分类为许多不同类型的文档。当我们在基类Document上运行查询时(例如" FROM Document WHERE Locked = 1"),Hibernate会生成有问题的SQL查询。这导致了一个非常长的SQL查询,它将所有子类表连接在一起(例如下面的例子),有时会杀死服务器。

我在测试时发现的一些有趣的事情:

  1. 只有在存在大量空连接表的情况下才会发生这种情况,这就是为什么它是如此追踪的原因 - 在我们的开发或测试数据库上运行时从未发生过,因为它们有足够的数据。因此,同一个查询在一个实例中即时运行而没有问题,并在另一个实例中完全杀死SQL服务器。
  2. 我一开始认为SQL查询中的大量选定列可能会导致问题,因此我使用相同的连接测试了SQL查询,但只选择了每个表中的一个列,因此只有少量数据是实际上被选中 - 没有改善,仍然挂着。
  3. 我对没有数据的数据库运行了查询,我开始逐个删除连接。我发现我可以达到查询运行并快速运行的程度。从这一点开始添加连接将导致查询运行,但速度明显变慢,并且重复这几次会最终导致它再次停止并终止服务器。
  4. 基于上述情况,我猜测在SQL Server中存在一个错误(或者我知道的一个已知的事实),因此连接导致过多的空值会导致问题。我认为这可能是一个错误,而不是一个已知的限制,因为它不会导致错误消息(例如,如果您尝试在IN子句中使用超过2100个项目的查询,您会得到),而是挂起服务器。服务器进入la-la land几乎就像连接导致了一个cartesion产品,但它恰恰相反 - 而不是大量的数据,我没有数据。

    还有其他人遇到过这样的问题吗?是否有一些已知的SQL服务器限制?我在搜索问题时遇到了很大困难,因为很难定义。 我应该为此向微软提交一个错误吗?

    非常感谢任何见解。如果我需要更多信息,请告诉我。

    感谢。

    示例查询如下(为简洁起见,我删除了大部分选定的列):

    select
        top 1 document0_.ID as ID715_,
        document0_.CreatedOn as CreatedOn715_,
        document0_.UpdatedOn as UpdatedOn715_,
        document0_.DeletedOn as DeletedOn715_,
        document0_.Deleted as Deleted715_,
        document0_.Active as Active715_,
        document0_.ActivatedOn as Activate8_715_,
        document0_.DeactivatedOn as Deactiva9_715_,
        document0_.Locked as Locked715_,
        document0_.CompletedDate as Complet11_715_,
        document0_.CreateUserID as CreateU23_715_,
        document0_.UpdateUserID as UpdateU24_715_,
        document0_1_.CreatedOn as CreatedOn717_,
        document0_1_.UpdatedOn as UpdatedOn717_,
        document0_1_.DeletedOn as DeletedOn717_,
        document0_1_.Deleted as Deleted717_,
        document0_1_.Active as Active717_,
        document0_1_.ActivatedOn as Activate7_717_,
        document0_1_.DeactivatedOn as Deactiva8_717_,
        document0_1_.Locked as Locked717_,
        document0_1_.DateReceived as DateRec10_717_,
        document0_1_.DateIssued as DateIssued717_,
        document0_1_.CreateUserID as CreateU12_717_,
        document0_1_.UpdateUserID as UpdateU13_717_,
        document0_2_.CreatedOn as CreatedOn733_,
        document0_2_.UpdatedOn as UpdatedOn733_,
        document0_2_.DeletedOn as DeletedOn733_,
        document0_2_.Deleted as Deleted733_,
        document0_2_.Active as Active733_,
        document0_2_.ActivatedOn as Activate7_733_,
        document0_2_.DeactivatedOn as Deactiva8_733_,
        document0_2_.Locked as Locked733_,
        document0_3_.CreatedOn as CreatedOn739_,
        document0_3_.UpdatedOn as UpdatedOn739_,
        document0_3_.DeletedOn as DeletedOn739_,
        document0_3_.Deleted as Deleted739_,
        document0_3_.Active as Active739_,
        document0_3_.ActivatedOn as Activate7_739_,
        document0_3_.DeactivatedOn as Deactiva8_739_,
        document0_3_.Locked as Locked739_,
        document0_4_.CreatedOn as CreatedOn754_,
        document0_4_.UpdatedOn as UpdatedOn754_,
        document0_4_.DeletedOn as DeletedOn754_,
        document0_4_.Deleted as Deleted754_,
        document0_4_.Active as Active754_,
        document0_4_.ActivatedOn as Activate7_754_,
        document0_4_.DeactivatedOn as Deactiva8_754_,
        document0_4_.Locked as Locked754_,
        document0_5_.CreatedOn as CreatedOn755_,
        document0_5_.UpdatedOn as UpdatedOn755_,
        document0_5_.DeletedOn as DeletedOn755_,
        document0_5_.Deleted as Deleted755_,
        document0_5_.Active as Active755_,
        document0_5_.ActivatedOn as Activate7_755_,
        document0_5_.DeactivatedOn as Deactiva8_755_,
        document0_5_.Locked as Locked755_,
        document0_6_.CreatedOn as CreatedOn759_,
        document0_6_.UpdatedOn as UpdatedOn759_,
        document0_6_.DeletedOn as DeletedOn759_,
        document0_6_.Deleted as Deleted759_,
        document0_6_.Active as Active759_,
        document0_6_.ActivatedOn as Activate7_759_,
        document0_6_.DeactivatedOn as Deactiva8_759_,
        document0_6_.Locked as Locked759_,
        document0_7_.CreatedOn as CreatedOn773_,
        document0_7_.UpdatedOn as UpdatedOn773_,
        document0_7_.DeletedOn as DeletedOn773_,
        document0_7_.Deleted as Deleted773_,
        document0_7_.Active as Active773_,
        document0_7_.ActivatedOn as Activate7_773_,
        document0_7_.DeactivatedOn as Deactiva8_773_,
        document0_7_.Locked as Locked773_,
        document0_8_.CreatedOn as CreatedOn774_,
        document0_8_.UpdatedOn as UpdatedOn774_,
        document0_8_.DeletedOn as DeletedOn774_,
        document0_8_.Deleted as Deleted774_,
        document0_8_.Active as Active774_,
        document0_8_.ActivatedOn as Activate7_774_,
        document0_8_.DeactivatedOn as Deactiva8_774_,
        document0_8_.Locked as Locked774_,
        document0_9_.CreatedOn as CreatedOn779_,
        document0_9_.UpdatedOn as UpdatedOn779_,
        document0_9_.DeletedOn as DeletedOn779_,
        document0_9_.Deleted as Deleted779_,
        document0_9_.Active as Active779_,
        document0_9_.ActivatedOn as Activate7_779_,
        document0_9_.DeactivatedOn as Deactiva8_779_,
        document0_9_.Locked as Locked779_,
        document0_10_.CreatedOn as CreatedOn780_,
        document0_10_.UpdatedOn as UpdatedOn780_,
        document0_10_.DeletedOn as DeletedOn780_,
        document0_10_.Deleted as Deleted780_,
        document0_10_.Active as Active780_,
        document0_10_.ActivatedOn as Activate7_780_,
        document0_10_.DeactivatedOn as Deactiva8_780_,
        document0_10_.Locked as Locked780_,
        document0_11_.CreatedOn as CreatedOn781_,
        document0_11_.UpdatedOn as UpdatedOn781_,
        document0_11_.DeletedOn as DeletedOn781_,
        document0_11_.Deleted as Deleted781_,
        document0_11_.Active as Active781_,
        document0_11_.ActivatedOn as Activate7_781_,
        document0_11_.DeactivatedOn as Deactiva8_781_,
        document0_11_.Locked as Locked781_,
        document0_11_.ExpiryDate as ExpiryDate781_,
        document0_11_.Number as Number781_,
        document0_11_.CreateUserID as CreateU12_781_,
        document0_11_.UpdateUserID as UpdateU13_781_,
        document0_12_.CreatedOn as CreatedOn784_,
        document0_12_.UpdatedOn as UpdatedOn784_,
        document0_12_.DeletedOn as DeletedOn784_,
        document0_12_.Deleted as Deleted784_,
        document0_12_.Active as Active784_,
        document0_12_.ActivatedOn as Activate7_784_,
        document0_12_.DeactivatedOn as Deactiva8_784_,
        document0_12_.Locked as Locked784_,
        document0_12_.CreateUserID as CreateU10_784_,
        document0_12_.UpdateUserID as UpdateU11_784_,
        document0_12_.SurveyID as SurveyID784_,
        document0_13_.CreatedOn as CreatedOn789_,
        document0_13_.UpdatedOn as UpdatedOn789_,
        document0_13_.DeletedOn as DeletedOn789_,
        document0_13_.Deleted as Deleted789_,
        document0_13_.Active as Active789_,
        document0_13_.ActivatedOn as Activate7_789_,
        document0_13_.DeactivatedOn as Deactiva8_789_,
        document0_13_.Locked as Locked789_,
        document0_14_.CreatedOn as CreatedOn790_,
        document0_14_.UpdatedOn as UpdatedOn790_,
        document0_14_.DeletedOn as DeletedOn790_,
        document0_14_.Deleted as Deleted790_,
        document0_14_.Active as Active790_,
        document0_14_.ActivatedOn as Activate7_790_,
        document0_14_.DeactivatedOn as Deactiva8_790_,
        document0_14_.Locked as Locked790_,
        document0_14_.aboriginal as aboriginal790_,
        document0_14_.disability as disability790_,
        document0_14_.minority as minority790_,
        document0_14_.refuse as refuse790_,
        document0_14_.CreateUserID as CreateU14_790_,
        document0_14_.UpdateUserID as UpdateU15_790_,
        document0_15_.CreatedOn as CreatedOn791_,
        document0_15_.UpdatedOn as UpdatedOn791_,
        document0_15_.DeletedOn as DeletedOn791_,
        document0_15_.Deleted as Deleted791_,
        document0_15_.Active as Active791_,
        document0_15_.ActivatedOn as Activate7_791_,
        document0_15_.DeactivatedOn as Deactiva8_791_,
        document0_15_.Locked as Locked791_,
        document0_15_.TypeOfTraining as TypeOfT10_791_,
        document0_15_.Location as Location791_,
        document0_15_.TrainerName as Trainer12_791_,
        document0_15_.[Result] as Result13_791_,
        document0_15_.TrainingDate as Trainin14_791_,
        document0_15_.ExpiryDate as ExpiryDate791_,
        document0_15_.CreateUserID as CreateU16_791_,
        document0_15_.UpdateUserID as UpdateU17_791_,
        document0_16_.CreatedOn as CreatedOn792_,
        document0_16_.UpdatedOn as UpdatedOn792_,
        document0_16_.DeletedOn as DeletedOn792_,
        document0_16_.Deleted as Deleted792_,
        document0_16_.Active as Active792_,
        document0_16_.ActivatedOn as Activate7_792_,
        document0_16_.DeactivatedOn as Deactiva8_792_,
        document0_16_.Locked as Locked792_,
        document0_16_.CreateUserID as CreateU10_792_,
        document0_16_.UpdateUserID as UpdateU11_792_,
        document0_17_.CreatedOn as CreatedOn793_,
        document0_17_.UpdatedOn as UpdatedOn793_,
        document0_17_.DeletedOn as DeletedOn793_,
        document0_17_.Deleted as Deleted793_,
        document0_17_.Active as Active793_,
        document0_17_.ActivatedOn as Activate7_793_,
        document0_17_.DeactivatedOn as Deactiva8_793_,
        document0_17_.Locked as Locked793_,
        document0_17_.Content as Content793_,
        document0_17_.CreateUserID as CreateU11_793_,
        document0_17_.UpdateUserID as UpdateU12_793_,
        document0_18_.CreatedOn as CreatedOn795_,
        document0_18_.UpdatedOn as UpdatedOn795_,
        document0_18_.DeletedOn as DeletedOn795_,
        document0_18_.Deleted as Deleted795_,
        document0_18_.Active as Active795_,
        document0_18_.ActivatedOn as Activate7_795_,
        document0_18_.DeactivatedOn as Deactiva8_795_,
        document0_18_.Locked as Locked795_,
        document0_19_.CreatedOn as CreatedOn800_,
        document0_19_.UpdatedOn as UpdatedOn800_,
        document0_19_.DeletedOn as DeletedOn800_,
        document0_19_.Deleted as Deleted800_,
        document0_19_.Active as Active800_,
        document0_19_.ActivatedOn as Activate7_800_,
        document0_19_.DeactivatedOn as Deactiva8_800_,
        document0_19_.Locked as Locked800_,
        document0_20_.CreatedOn as CreatedOn802_,
        document0_20_.UpdatedOn as UpdatedOn802_,
        document0_20_.DeletedOn as DeletedOn802_,
        document0_20_.Deleted as Deleted802_,
        document0_20_.Active as Active802_,
        document0_20_.ActivatedOn as Activate7_802_,
        document0_20_.DeactivatedOn as Deactiva8_802_,
        document0_20_.Locked as Locked802_,
        document0_20_.StartDate as StartDate802_,
        document0_20_.EndDate as EndDate802_,
        document0_21_.CreatedOn as CreatedOn807_,
        document0_21_.UpdatedOn as UpdatedOn807_,
        document0_21_.DeletedOn as DeletedOn807_,
        document0_21_.Deleted as Deleted807_,
        document0_21_.Active as Active807_,
        document0_21_.ActivatedOn as Activate7_807_,
        document0_21_.DeactivatedOn as Deactiva8_807_,
        document0_21_.Locked as Locked807_,
        document0_21_.CreateUserID as CreateU18_807_,
        document0_21_.UpdateUserID as UpdateU19_807_,
        document0_21_.EducationLevelTypeID as Educati21_807_,
        document0_22_.CreatedOn as CreatedOn808_,
        document0_22_.UpdatedOn as UpdatedOn808_,
        document0_22_.DeletedOn as DeletedOn808_,
        document0_22_.Deleted as Deleted808_,
        document0_22_.Active as Active808_,
        document0_22_.ActivatedOn as Activate7_808_,
        document0_22_.DeactivatedOn as Deactiva8_808_,
        document0_22_.Locked as Locked808_,
        document0_22_.CreateUserID as CreateU10_808_,
        document0_22_.UpdateUserID as UpdateU11_808_,
        document0_23_.CreatedOn as CreatedOn809_,
        document0_23_.UpdatedOn as UpdatedOn809_,
        document0_23_.DeletedOn as DeletedOn809_,
        document0_23_.Deleted as Deleted809_,
        document0_23_.Active as Active809_,
        document0_23_.ActivatedOn as Activate7_809_,
        document0_23_.DeactivatedOn as Deactiva8_809_,
        document0_23_.Locked as Locked809_,
        document0_24_.CreatedOn as CreatedOn810_,
        document0_24_.UpdatedOn as UpdatedOn810_,
        document0_24_.DeletedOn as DeletedOn810_,
        document0_24_.Deleted as Deleted810_,
        document0_24_.Active as Active810_,
        document0_24_.ActivatedOn as Activate7_810_,
        document0_24_.DeactivatedOn as Deactiva8_810_,
        document0_24_.Locked as Locked810_,
        document0_24_.CreateUserID as CreateU10_810_,
        document0_24_.UpdateUserID as UpdateU11_810_,
        document0_25_.CreatedOn as CreatedOn811_,
        document0_25_.UpdatedOn as UpdatedOn811_,
        document0_25_.DeletedOn as DeletedOn811_,
        document0_25_.Deleted as Deleted811_,
        document0_25_.Active as Active811_,
        document0_25_.ActivatedOn as Activate7_811_,
        document0_25_.DeactivatedOn as Deactiva8_811_,
        document0_25_.Locked as Locked811_,
        document0_26_.CreatedOn as CreatedOn815_,
        document0_26_.UpdatedOn as UpdatedOn815_,
        document0_26_.DeletedOn as DeletedOn815_,
        document0_26_.Deleted as Deleted815_,
        document0_26_.Active as Active815_,
        document0_26_.ActivatedOn as Activate7_815_,
        document0_26_.DeactivatedOn as Deactiva8_815_,
        document0_26_.Locked as Locked815_,
        document0_27_.CreatedOn as CreatedOn816_,
        document0_27_.UpdatedOn as UpdatedOn816_,
        document0_27_.DeletedOn as DeletedOn816_,
        document0_27_.Deleted as Deleted816_,
        document0_27_.Active as Active816_,
        document0_27_.ActivatedOn as Activate7_816_,
        document0_27_.DeactivatedOn as Deactiva8_816_,
        document0_27_.Locked as Locked816_,
        document0_27_.DateReceived as DateRec10_816_,
        document0_27_.DateIssued as DateIssued816_,
        document0_27_.CreateUserID as CreateU12_816_,
        document0_27_.UpdateUserID as UpdateU13_816_,
        document0_28_.CreatedOn as CreatedOn819_,
        document0_28_.UpdatedOn as UpdatedOn819_,
        document0_28_.DeletedOn as DeletedOn819_,
        document0_28_.Deleted as Deleted819_,
        document0_28_.Active as Active819_,
        document0_28_.ActivatedOn as Activate7_819_,
        document0_28_.DeactivatedOn as Deactiva8_819_,
        document0_28_.Locked as Locked819_,
        document0_28_.LicenceDocumentNumber as Licence10_819_,
        document0_28_.DemeritPoints as Demerit11_819_,
        document0_28_.MeritPoints as MeritPo12_819_,
        document0_28_.ExpiryDate as ExpiryDate819_,
        document0_28_.CreateUserID as CreateU14_819_,
        document0_28_.UpdateUserID as UpdateU15_819_,
        document0_28_.LicenceDocumentStatusTypeID as Licence16_819_,
        document0_28_.StateProvinceID as StatePr17_819_,
        document0_29_.CreatedOn as CreatedOn820_,
        document0_29_.UpdatedOn as UpdatedOn820_,
        document0_29_.DeletedOn as DeletedOn820_,
        document0_29_.Deleted as Deleted820_,
        document0_29_.Active as Active820_,
        document0_29_.ActivatedOn as Activate7_820_,
        document0_29_.DeactivatedOn as Deactiva8_820_,
        document0_29_.Locked as Locked820_,
        document0_29_.CreateUserID as CreateU10_820_,
        document0_29_.UpdateUserID as UpdateU11_820_,
        document0_30_.CreatedOn as CreatedOn821_,
        document0_30_.UpdatedOn as UpdatedOn821_,
        document0_30_.DeletedOn as DeletedOn821_,
        document0_30_.Deleted as Deleted821_,
        document0_30_.Active as Active821_,
        document0_30_.ActivatedOn as Activate7_821_,
        document0_30_.DeactivatedOn as Deactiva8_821_,
        document0_30_.Locked as Locked821_,
        document0_30_.ExpiryDate as ExpiryDate821_,
        document0_30_.LicenceNumber as Licence11_821_,
        document0_30_.CreateUserID as CreateU12_821_,
        document0_30_.UpdateUserID as UpdateU13_821_,
        document0_30_.StateProvinceID as StatePr14_821_,
        document0_31_.CreatedOn as CreatedOn822_,
        document0_31_.UpdatedOn as UpdatedOn822_,
        document0_31_.DeletedOn as DeletedOn822_,
        document0_31_.Deleted as Deleted822_,
        document0_31_.Active as Active822_,
        document0_31_.ActivatedOn as Activate7_822_,
        document0_31_.DeactivatedOn as Deactiva8_822_,
        document0_31_.Locked as Locked822_,
        document0_32_.CreatedOn as CreatedOn823_,
        document0_32_.UpdatedOn as UpdatedOn823_,
        document0_32_.DeletedOn as DeletedOn823_,
        document0_32_.Deleted as Deleted823_,
        document0_32_.Active as Active823_,
        document0_32_.ActivatedOn as Activate7_823_,
        document0_32_.DeactivatedOn as Deactiva8_823_,
        document0_32_.Locked as Locked823_,
        document0_33_.CreatedOn as CreatedOn824_,
        document0_33_.UpdatedOn as UpdatedOn824_,
        document0_33_.DeletedOn as DeletedOn824_,
        document0_33_.Deleted as Deleted824_,
        document0_33_.Active as Active824_,
        document0_33_.ActivatedOn as Activate7_824_,
        document0_33_.DeactivatedOn as Deactiva8_824_,
        document0_33_.Locked as Locked824_,
        document0_33_.CreateUserID as CreateU10_824_,
        document0_33_.UpdateUserID as UpdateU11_824_,
        document0_34_.CreatedOn as CreatedOn825_,
        document0_34_.UpdatedOn as UpdatedOn825_,
        document0_34_.DeletedOn as DeletedOn825_,
        document0_34_.Deleted as Deleted825_,
        document0_34_.Active as Active825_,
        document0_34_.ActivatedOn as Activate7_825_,
        document0_34_.DeactivatedOn as Deactiva8_825_,
        document0_34_.Locked as Locked825_,
        document0_35_.CreatedOn as CreatedOn826_,
        document0_35_.UpdatedOn as UpdatedOn826_,
        document0_35_.DeletedOn as DeletedOn826_,
        document0_35_.Deleted as Deleted826_,
        document0_35_.Active as Active826_,
        document0_35_.ActivatedOn as Activate7_826_,
        document0_35_.DeactivatedOn as Deactiva8_826_,
        document0_35_.Locked as Locked826_,
        document0_35_.ExpiryDate as ExpiryDate826_,
        document0_35_.CreateUserID as CreateU11_826_,
        document0_35_.UpdateUserID as UpdateU12_826_,
        document0_36_.CreatedOn as CreatedOn827_,
        document0_36_.UpdatedOn as UpdatedOn827_,
        document0_36_.DeletedOn as DeletedOn827_,
        document0_36_.Deleted as Deleted827_,
        document0_36_.Active as Active827_,
        document0_36_.ActivatedOn as Activate7_827_,
        document0_36_.DeactivatedOn as Deactiva8_827_,
        document0_36_.Locked as Locked827_,
        document0_36_.ExpiryDate as ExpiryDate827_,
        document0_36_.CreateUserID as CreateU11_827_,
        document0_36_.UpdateUserID as UpdateU12_827_,
        document0_37_.CreatedOn as CreatedOn829_,
        document0_37_.UpdatedOn as UpdatedOn829_,
        document0_37_.DeletedOn as DeletedOn829_,
        document0_37_.Deleted as Deleted829_,
        document0_37_.Active as Active829_,
        document0_37_.ActivatedOn as Activate7_829_,
        document0_37_.DeactivatedOn as Deactiva8_829_,
        document0_37_.Locked as Locked829_,
        document0_37_.CheckDate as CheckDate829_,
        document0_37_.CreateUserID as CreateU11_829_,
        document0_37_.UpdateUserID as UpdateU12_829_,
        document0_38_.CreatedOn as CreatedOn830_,
        document0_38_.UpdatedOn as UpdatedOn830_,
        document0_38_.DeletedOn as DeletedOn830_,
        document0_38_.Deleted as Deleted830_,
        document0_38_.Active as Active830_,
        document0_38_.ActivatedOn as Activate7_830_,
        document0_38_.DeactivatedOn as Deactiva8_830_,
        document0_38_.Locked as Locked830_,
        document0_39_.CreatedOn as CreatedOn831_,
        document0_39_.UpdatedOn as UpdatedOn831_,
        document0_39_.DeletedOn as DeletedOn831_,
        document0_39_.Deleted as Deleted831_,
        document0_39_.Active as Active831_,
        document0_39_.ActivatedOn as Activate7_831_,
        document0_39_.DeactivatedOn as Deactiva8_831_,
        document0_39_.Locked as Locked831_,
        document0_40_.CreatedOn as CreatedOn832_,
        document0_40_.UpdatedOn as UpdatedOn832_,
        document0_40_.DeletedOn as DeletedOn832_,
        document0_40_.Deleted as Deleted832_,
        document0_40_.Active as Active832_,
        document0_40_.ActivatedOn as Activate7_832_,
        document0_40_.DeactivatedOn as Deactiva8_832_,
        document0_40_.Locked as Locked832_,
        document0_41_.CreatedOn as CreatedOn833_,
        document0_41_.UpdatedOn as UpdatedOn833_,
        document0_41_.DeletedOn as DeletedOn833_,
        document0_41_.Deleted as Deleted833_,
        document0_41_.Active as Active833_,
        document0_41_.ActivatedOn as Activate7_833_,
        document0_41_.DeactivatedOn as Deactiva8_833_,
        document0_41_.Locked as Locked833_,
        document0_41_.CreateUserID as CreateU10_833_,
        document0_41_.UpdateUserID as UpdateU11_833_,
        document0_.Subtype as Subtype715_ 
    from
        Document document0_ 
    left outer join
        CustomDocument1 document0_1_ 
            on document0_.ID=document0_1_.DocumentID 
    left outer join
        CustomDocument2 document0_2_ 
            on document0_.ID=document0_2_.DocumentID 
    left outer join
        CustomDocument3 document0_3_ 
            on document0_.ID=document0_3_.DocumentID 
    left outer join
        CustomDocument4 document0_4_ 
            on document0_.ID=document0_4_.DocumentID 
    left outer join
        CustomDocument5 document0_5_ 
            on document0_.ID=document0_5_.DocumentID 
    left outer join
        CustomDocument6 document0_6_ 
            on document0_.ID=document0_6_.DocumentID 
    left outer join
        CustomDocument7 document0_7_ 
            on document0_.ID=document0_7_.DocumentID 
    left outer join
        CustomDocument8 document0_8_ 
            on document0_.ID=document0_8_.DocumentID 
    left outer join
        CustomDocument9 document0_9_ 
            on document0_.ID=document0_9_.DocumentID 
    left outer join
        CustomDocument10 document0_10_ 
            on document0_.ID=document0_10_.DocumentID 
    left outer join
        CustomDocument11 document0_11_ 
            on document0_.ID=document0_11_.DocumentID 
    left outer join
        CustomDocument12 document0_12_ 
            on document0_.ID=document0_12_.DocumentID 
    left outer join
        CustomDocument13 document0_13_ 
            on document0_.ID=document0_13_.DocumentID 
    left outer join
        CustomDocument14 document0_14_ 
            on document0_.ID=document0_14_.DocumentID 
    left outer join
        CustomDocument15 document0_15_ 
            on document0_.ID=document0_15_.DocumentID 
    left outer join
        CustomDocument16 document0_16_ 
            on document0_.ID=document0_16_.DocumentID 
    left outer join
        CustomDocument17 document0_17_ 
            on document0_.ID=document0_17_.DocumentID 
    left outer join
        CustomDocument18 document0_18_ 
            on document0_.ID=document0_18_.DocumentID 
    left outer join
        CustomDocument19 document0_19_ 
            on document0_.ID=document0_19_.DocumentID 
    left outer join
        CustomDocument20 document0_20_ 
            on document0_.ID=document0_20_.DocumentID 
    left outer join
        CustomDocument21 document0_21_ 
            on document0_.ID=document0_21_.DocumentID 
    left outer join
        CustomDocument22 document0_22_ 
            on document0_.ID=document0_22_.DocumentID 
    left outer join
        CustomDocument23 document0_23_ 
            on document0_.ID=document0_23_.DocumentID 
    left outer join
        CustomDocument24 document0_24_ 
            on document0_.ID=document0_24_.DocumentID 
    left outer join
        CustomDocument25 document0_25_ 
            on document0_.ID=document0_25_.DocumentID 
    left outer join
        CustomDocument26 document0_26_ 
            on document0_.ID=document0_26_.DocumentID 
    left outer join
        CustomDocument27 document0_27_ 
            on document0_.ID=document0_27_.DocumentID 
    left outer join
        CustomDocument28 document0_28_ 
            on document0_.ID=document0_28_.DocumentID 
    left outer join
        CustomDocument29 document0_29_ 
            on document0_.ID=document0_29_.DocumentID 
    left outer join
        CustomDocument30 document0_30_ 
            on document0_.ID=document0_30_.DocumentID 
    left outer join
        CustomDocument31 document0_31_ 
            on document0_.ID=document0_31_.DocumentID 
    left outer join
        CustomDocument32 document0_32_ 
            on document0_.ID=document0_32_.DocumentID 
    left outer join
        CustomDocument33 document0_33_ 
            on document0_.ID=document0_33_.DocumentID 
    left outer join
        CustomDocument34 document0_34_ 
            on document0_.ID=document0_34_.DocumentID 
    left outer join
        CustomDocument35 document0_35_ 
            on document0_.ID=document0_35_.DocumentID 
    left outer join
        CustomDocument36 document0_36_ 
            on document0_.ID=document0_36_.DocumentID 
    left outer join
        CustomDocument37 document0_37_ 
            on document0_.ID=document0_37_.DocumentID 
    left outer join
        CustomDocument38 document0_38_ 
            on document0_.ID=document0_38_.DocumentID 
    left outer join
        CustomDocument39 document0_39_ 
            on document0_.ID=document0_39_.DocumentID 
    left outer join
        CustomDocument40 document0_40_ 
            on document0_.ID=document0_40_.DocumentID 
    left outer join
        CustomDocument41 document0_41_ 
            on document0_.ID=document0_41_.DocumentID 
    where
        document0_.DocumentTypeID=? 
        and document0_.Locked=?
    

1 个答案:

答案 0 :(得分:1)

感谢@TabAlleman,@ Ionic等。这些评论让我意识到执行计划的计算正在吸收这么多资源。这种理解使我发现this SO question询问执行计划需要很长时间才能在SQL Server 2014中生成。

我应该提到我们正在使用SQL Server 2014,因为事实证明这个版本引入了一个积极的新查询优化器,它在查询中遇到问题。如果我将数据库兼容性设置为SQL Server 2012,则会立即生成执行计划。

我仍然可以在SQL Connect中记录一个错误,因为此查询可能代表需要查看的边缘情况。

谢谢大家。