问题标签 [sqlperformance]
For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.
database - 更新 DB varchar 列时如何避免物理表溢出
运行数据库统计信息我在更新表时看到很多物理溢出。
我相信原因是 varchar 列以 null 开头,然后更新为 ~20 个字符的值。当发生这种情况时,记录会从物理页面溢出,因此分配了一个新页面,导致数据局部性错误,直到我重新组织表。
我如何提示数据库为高级记录分配足够的空间,以便当我将其 varchar 列从 null 更新为字符串时它不会溢出?
- 我无法切换到固定长度的 CHAR 列类型,因为我没有预定义的最大长度。
- 我宁愿不使用魔法值而不是空值(比如“00000000000000000000”)作为预分配器。
- 我的主要用例是 DB2,但也想知道 MSSQL 和 oracle。
sql - SQL 删除请求在“索引删除”中花费大量时间,即使它影响 0 行
我使用 MSSQL Server 2008,我有简单条件的 SQL 请求,它定期从表中删除旧记录(表中约 3 百万条记录)。
即使它影响 0 行,该请求也会执行大量时间(约 10 秒)。
该表有一些索引,在实际执行计划中我看到“索引删除”操作消耗了所有执行时间。
如果没有任何行受删除操作影响,为什么 SQL Server 会在索引上做很多工作?
更新:
要求:
实际执行计划 XML:pastebin.com/up2E3iP1
sql-server - TimeOut 已过期:使用 nHibernate 时出现 Sql 异常
在检查了更多细节后,我了解了以下发现。我无法获得内部异常,所以我在提琴手中运行它以检查是否可以从中获取一些信息。提琴手有以下详细信息
[GenericADOException: 无法执行查询 [ SELECT this_.CompanyId as CompanyId0_30_, this_.HooversCompanyId as HooversC2_0_30_, this_.DUNS as DUNS0_30_, this_.CompanyName as CompanyN4_0_30_, this_.AddressLine1 as AddressL5_0_30_, this_.AddressLine2 as AddressL6_0_30_, this_.State as State0 , this_.City 为 City0_30_, this_.ZipCode 为 ZipCode0_30_, this_.CountryTelephoneAccessCode 为 Country10_0_30_, this_.TelephoneNumber 为 Telepho11_0_30_, this_.FaxNumber 为 FaxNumber0_30_, this_.Revenue 为 Revenue0_30_, this_.FinancialYearEndDate 为 Financi14_0_30e15, this___0_0 .EmployeesHereTotal 作为 Employe16_0_30_, this_.LegalStructure 作为 LegalSt17_0_30_, this_.ProfitLoss 作为 ProfitLoss0_30_, this_.NetWorth 作为 NetWorth0_30_, this_.HasSubsidariesIndicator 作为 HasSubs20_0_30_, this_。ITSpendingUpdateDate as ITSpend21_0_30_, this_.ITSpending as ITSpending0_30_, this_.ITSpendingNextYearPrediction as ITSpend23_0_30_, this_.ITSpendingGrowth as ITSpend24_0_30_, this_.AuditCreatedDate as AuditCr25_0_30_, this_.AuditModifiedDate as AuditMo26_0_30_, this_.Website as Website0_30_, this_.OwnershipTypeId as Ownersh28_0_30_, this_.CompanyStatusId as Company29_0_30_, this_.RecordTypeId as RecordT30_0_30_, this_.LocationTypeId as Locatio31_0_30_, this_.ZipCodeId as ZipCodeId0_30_, this_.PrimarySIC_Code as PrimarySIC33_0_30_, this_.StateId as StateId0_30_, this_.CountryId as CountryId0_30_, this_.SWOTAnalysisId as SWOTAna36_0_30_, primaryind2_.CompanyId as CompanyId32_, primaryind2_.CompanyIndustryId 作为 CompanyI1_32_,primaryind2_.CompanyIndustryId 作为 CompanyI1_8_0_,primaryind2_.IsPrimary 作为 IsPrimary8_0_,primaryind2_.CompanyId 作为 CompanyId8_0_,primaryind2_.HIC 作为 HIC8_0_,industry3_.HIC 作为 HIC6_1_,industry3_.Name 作为 Name6_1_,industry3_.Level 作为 Level6_1_,industry3_.ParentHIC 作为 ParentHIC6_1_,itspending4_.CompanyId 作为 CompanyId33_,itspending4_.ITSpendingId 作为 ITSPendi1_33_,itspending4_ ITSpendingId as ITSpendi1_14_2_, itspending4_.Amount as Amount14_2_, itspending4_.CompanyId as CompanyId14_2_, itspending4_.ITSpendingTypeId as ITSpendi3_14_2_, itspending5_.ITSpendingTypeID as ITSpendi1_15_3_, itspending5_.Name as Name15_3_, itspending5_.ParentID as ParentID15_3_, hardware6_.CompanyId as CompanyId34_, hardware6_.ITSpendingId as ITSpendi1_34_,hardware6_.ITSpendingId 作为 ITSpendi1_14_4_,hardware6_.Amount 作为 Amount14_4_,hardware6_.CompanyId 作为 CompanyId14_4_,hardware6_.ITSpendingTypeId 作为 ITSpendi3_14_4_,computingp7_.CompanyId as CompanyId35_, computingp7_.ITSpendingId as ITSpendi1_35_, computingp7_.ITSpendingId as ITSpendi1_14_5_, computingp7_.Amount as Amount14_5_, computingp7_.CompanyId as CompanyId14_5_, computingp7_.ITSpendingTypeId as ITSpendi3_14_5_, networking8_.CompanyId as CompanyId36_, networking8_.ITSpendingId as ITSpendi1_36_, networking8_. ITSpendingId as ITSpendi1_14_6_, networking8_.Amount as Amount14_6_, networking8_.CompanyId as CompanyId14_6_, networking8_.ITSpendingTypeId as ITSpendi3_14_6_, serversand9_.CompanyId as CompanyId37_, serversand9_.ITSpendingId as ITSpendi1_37_, serversand9_.ITSpendingId as ITSpendi1_14_7_, serversand9_.Amount as Amount14_7_, serversand9_.CompanyId as CompanyId14_7_、serversand9_.ITSpendingTypeId 作为 ITSpendi3_14_7_、software10_.CompanyId 作为 CompanyId38_、software10_。ITSpendingId as ITSpendi1_38_, software10_.ITSpendingId as ITSpendi1_14_8_, software10_.Amount as Amount14_8_, software10_.CompanyId as CompanyId14_8_, software10_.ITSpendingTypeId as ITSpendi3_14_8_, softwareli11_.CompanyId as CompanyId39_, softwareli11_.ITSpendingId as ITSpendi1_39_, softwareli11_.ITSpendingId as ITSpendi1_14_9_, softwareli11_.Amount as Amount14_9_, softwareli11_.CompanyId as CompanyId14_9_, softwareli11_.ITSpendingTypeId as ITSpendi3_14_9_, supportand12_.CompanyId as CompanyId40_, supportand12_.ITSpendingId as ITSpendi1_40_, supportand12_.ITSpendingId as ITSpendi1_14_10_, supportand12_.Amount as Amount14_10_, supportand12_.CompanyId as CompanyId14_10_, supportand12_.ITSpendingTypeId as ITSpendi3_14_10_, services13_.CompanyId 作为 CompanyId41_,services13_.ITSpendingId 作为 ITSpendi1_41_,services13_。ITSpendingId as ITSpendi1_14_11_, services13_.Amount as Amount14_11_, services13_.CompanyId as CompanyId14_11_, services13_.ITSpendingTypeId as ITSpendi3_14_11_, applicatio14_.CompanyId as CompanyId42_, applicatio14_.ITSpendingId as ITSpendi1_42_, applicatio14_.ITSpendingId as ITSpendi1_14_12_, applicatio14_.Amount as Amount14_12_, applicatio14_.CompanyId as CompanyId14_12_, applicatio14_.ITSpendingTypeId as ITSpendi3_14_12_, infrastruc15_.CompanyId as CompanyId43_, infrastruc15_.ITSpendingId as ITSpendi1_43_, infrastruc15_.ITSpendingId as ITSpendi1_14_13_, infrastruc15_.Amount as Amount14_13_, infrastruc15_.CompanyId as CompanyId14_13_, infrastruc15_.ITSpendingTypeId as ITSpendi3_14_13_, helpdeskan16_.CompanyId as CompanyId44_, helpdeskan16_.ITSpendingId 作为 ITSpendi1_44_, helpdeskan16_.ITSpendingId 作为 ITSpendi1_14_14_,helpdeskan16_.Amount as Amount14_14_, helpdeskan16_.CompanyId as CompanyId14_14_, helpdeskan16_.ITSpendingTypeId as ITSpendi3_14_14_, communicat17_.CompanyId as CompanyId45_, communicat17_.ITSpendingId as ITSpendi1_45_, communicat17_.ITSpendingId as ITSpendi1_14_15_, communicat17_.Amount as Amount14_15_, communicat17_.CompanyId as CompanyId14_15_, communicat17_. ITSpendingTypeId as ITSpendi3_14_15_, voiceservi18_.CompanyId as CompanyId46_, voiceservi18_.ITSpendingId as ITSpendi1_46_, voiceservi18_.ITSpendingId as ITSpendi1_14_16_, voiceservi18_.Amount as Amount14_16_, voiceservi18_.CompanyId as CompanyId14_16_, voiceservi18_.ITSpendingTypeId as ITSpendi3_14_16_, dataservic19_.CompanyId as CompanyId47_, dataservic19_.ITSpendingId as ITSpendi1_47_、dataservic19_.ITSpendingId 为 ITSpendi1_14_17_、dataservic19_。Amount as Amount14_17_, dataservic19_.CompanyId as CompanyId14_17_, dataservic19_.ITSpendingTypeId as ITSpendi3_14_17_, convergeds20_.CompanyId as CompanyId48_, convergeds20_.ITSpendingId as ITSpendi1_48_, convergeds20_.ITSpendingId as ITSpendi1_14_18_, convergeds20_.Amount as Amount14_18_, convergeds20_.CompanyId as CompanyId14_18_, convergeds20_.ITSpendingTypeId as ITSpendi3_14_18_, consulting21_.CompanyId as CompanyId49_, consulting21_.ITSpendingId as ITSpendi1_49_, consulting21_.ITSpendingId as ITSpendi1_14_19_, consulting21_.Amount as Amount14_19_, consulting21_.CompanyId as CompanyId14_19_, consulting21_.ITSpendingTypeId as ITSpendi3_14_19_, systemspla22_.CompanyId as CompanyId50_, systemspla22_.ITSpendingId as ITSpendi1_50_, systemspla22_.ITSpendingId 作为 ITSpendi1_14_20_,systemspla22_.Amount 作为 Amount14_20_,systemspla22_.CompanyId as CompanyId14_20_, systemspla22_.ITSpendingTypeId as ITSpendi3_14_20_, disasterre23_.CompanyId as CompanyId51_, disasterre23_.ITSpendingId as ITSpendi1_51_, disasterre23_.ITSpendingId as ITSpendi1_14_21_, disasterre23_.Amount as Amount14_21_, disasterre23_.CompanyId as CompanyId14_21_, disasterre23_.ITSpendingTypeId as ITSpendi3_14_21_, traininged24_. CompanyId as CompanyId52_, traininged24_.ITSpendingId as ITSpendi1_52_, traininged24_.ITSpendingId as ITSpendi1_14_22_, traininged24_.Amount as Amount14_22_, traininged24_.CompanyId as CompanyId14_22_, traininged24_.ITSpendingTypeId as ITSpendi3_14_22_, internalit25_.CompanyId as CompanyId53_, internalit25_.ITSpendingId as ITSpendi1_53_, internalit25_.ITSpendingId as ITSpendi1_14_23_,internalit25_。金额为 Amount14_23_,internalit25_。CompanyId as CompanyId14_23_, internalit25_.ITSpendingTypeId as ITSpendi3_14_23_, telco26_.CompanyId as CompanyId54_, telco26_.ITSpendingId as ITSpendi1_54_, telco26_.ITSpendingId as ITSpendi1_14_24_, telco26_.Amount as Amount14_24_, telco26_.CompanyId as CompanyId14_24_, telco26_.ITSpendingTypeId as ITSpendi3_14_24_, systemsint27_.CompanyId as CompanyId55_, systemsint27_.ITSpendingId as ITSpendi1_55_, systemsint27_.ITSpendingId as ITSpendi1_14_25_, systemsint27_.Amount as Amount14_25_, systemsint27_.CompanyId as CompanyId14_25_, systemsint27_.ITSpendingTypeId as ITSpendi3_14_25_, zipcode28_.ZipCodeId as ZipCodeId27_26_, zipcode28_.ZipCode as ZipCode27_26_, siccode29_.Code as Code20_27_, siccode29_.Name 为 Name20_27_,country30_.CountryId 为 CountryId4_28_,country30_.Name 为 Name4_28_,country30_。GeographyId as Geograph3_4_28_, contractsa31_.CompanyId as CompanyId3_29_, contractsa31_.ActiveContractValue as ActiveCo2_3_29_, contractsa31_.ActiveContractVolume as ActiveCo3_3_29_, contractsa31_.TotalContractValue as TotalCon4_3_29_, contractsa31_.TotalContractVolume as TotalCon5_3_29_, contractsa31_.RelationshipVendor as Relation6_3_29_ FROM Company this_ left outer join CompanyIndustry primaryind2_ on this_. CompanyId=primaryind2_.CompanyId 和 (primaryind2_.IsPrimary = 1) 左外连接 HooversIndustry industry3_ on primaryind2_.HIC=industry3_.HIC 左外连接 ITSpending itspending4_ on this_.CompanyId=itspending4_.CompanyId 左外连接 ITSpendingType itspending5_ on itspending4_.ITSpendingTypeId=itspending5_ .ITSpendingTypeID 在 this_.CompanyId=hardware6_ 上左外连接 ITSpending hardware6_。CompanyId 和 (hardware6_.ITSpendingTypeId = 2) 左外连接 ITSpending 计算 p7_ on this_.CompanyId=computingp7_.CompanyId 和 (computingp7_.ITSpendingTypeId = 12) 左外连接 ITSpending network8_ on this_.CompanyId=networking8_.CompanyId 和 (networking8_.ITSpendingTypeId = 11 ) 在 this_.CompanyId=serversand9_.CompanyId 和 (serversand9_.ITSpendingTypeId = 10) 在 this_.CompanyId=software10_.CompanyId 和 (software10_.ITSpendingTypeId = 3) 在 this_ 上左外连接 ITSpending softwareli11_ .CompanyId=softwareli11_.CompanyId 和 (softwareli11_.ITSpendingTypeId = 15) 在 this_.CompanyId=supportand12_.CompanyId 和 (supportand12_.ITSpendingTypeId = 16) 左外连接 ITSpending services13_ on this_.CompanyId=services13_.CompanyId 和 (services13_.ITSpendingTypeId = 4) 左外连接 ITSpending applicatio14_ on this_.CompanyId=application14_.CompanyId 和 (application14_.ITSpendingTypeId = 19) 左外连接 ITSpending infrastruc15_ on this_.CompanyId=infrastruc15_.CompanyId 和 (infrastruc15_.ITSpendingTypeId = 20) 左外连接 ITSpending helpdeskan16_ on this_.CompanyId=helpdeskan16_.CompanyId 和 (helpdeskan16_.ITSpendingTypeId = 21) 左外连接 ITSpending Communcat17_ on this_.CompanyId=communicat17_。 CompanyId 和 (communicat17_.ITSpendingTypeId = 5) 左外连接 ITSpending voiceservi18_ on this_.CompanyId=voiceservi18_.CompanyId 和 (voiceservi18_.ITSpendingTypeId = 24) 左外连接 ITSpending dataservic19_ on this_。CompanyId=dataservic19_.CompanyId 和 (dataservic19_.ITSpendingTypeId = 25) 左外连接 ITSpending convergeds20_ on this_.CompanyId=convergeds20_.CompanyId 和 (convergeds20_.ITSpendingTypeId = 26) 左外连接 ITSpending Consulting21_ on this_.CompanyId=consulting21_.CompanyId 和 (consulting21_ .ITSpendingTypeId = 6) 左外连接 ITSpending systemspla22_ on this_.CompanyId=systemspla22_.CompanyId 和 (systemspla22_.ITSpendingTypeId = 29) 左外连接 ITSpending disasterre23_ on this_.CompanyId=disasterre23_.CompanyId 和 (disasterre23_.ITSpendingTypeId = 30) 左外连接ITSpending traininged24_ on this_.CompanyId=traininged24_.CompanyId 和 (traininged24_.ITSpendingTypeId = 31) 左外连接 ITSpending internalit25_ on this_.CompanyId=internalit25_.CompanyId 和 (internalit25_.ITSpendingTypeId = 38) 左外连接 ITSpending telco26_ on this_.CompanyId=telco26_.CompanyId 和 (telco26_.ITSpendingTypeId = 35) 左外连接 ITSpending systemsint27_ on this_.CompanyId=systemsint27_.CompanyId 和 (systemsint27_.ITSpendingTypeId = 36) 左外连接 ZipCode zipcode28_ on this_.ZipCodeId=zipcode28_.ZipCodeId 左外连接 SICCode siccode29_ on this_.PrimarySIC_Code=siccode29_.Code 左外连接 Country country30_ on this_.CountryId=country30_.CountryId 左外连接 CompanyContractAggregation contracta31_ on this_.CompanyId=contractsa31_.CompanyId WHERE this_ .CompanyId in (@p0) ] Name:cp0 - Value:3506 [SQL: SELECT this_.CompanyId as CompanyId0_30_, this_.HooversCompanyId as HooversC2_0_30_, this_.DUNS as DUNS0_30_, this_.CompanyName as CompanyN4_0_30_, this_。AddressLine1 作为 AddressL5_0_30_, this_.AddressLine2 作为 AddressL6_0_30_, this_.State 作为 State0_30_, this_.City 作为 City0_30_, this_.ZipCode 作为 ZipCode0_30_, this_.CountryTelephoneAccessCode 作为 Country10_0_30_, this_.TelephoneNumber 作为 Telepho11_0_30_, this_.FaxNumber 作为 FaxNumber, this_Revenue 作为0_30_ Revenue0_30_, this_.FinancialYearEndDate as Financi14_0_30_, this_.EmployeesTotal as Employe15_0_30_, this_.EmployeesHereTotal as Employe16_0_30_, this_.LegalStructure as LegalSt17_0_30_, this_.ProfitLoss as ProfitLoss0_30_, this_.NetWorth as NetWorth0_30_, this_.HasSubsidariesIndicator as HasSubs20_0_30_, this_.ITSpendingUpdateDate as ITSpend21_0_30_, this_.ITSpending 作为 ITSpending0_30_,this_.ITSpendingNextYearPrediction 作为 ITSpend23_0_30_,this_.ITSpendingGrowth 作为 ITSpend24_0_30_,this_。AuditCreatedDate as AuditCr25_0_30_, this_.AuditModifiedDate as AuditMo26_0_30_, this_.Website as Website0_30_, this_.OwnershipTypeId as Ownersh28_0_30_, this_.CompanyStatusId as Company29_0_30_, this_.RecordTypeId as RecordT30_0_30_, this_.LocationTypeId as Locatio31_0_30_, this_.ZipCodeId as ZipCodeId0_30_, this_.PrimarySIC_Code as PrimarySIC33_0_30_, this_.StateId as StateId0_30_, this_.CountryId as CountryId0_30_, this_.SWOTAnalysisId as SWOTAna36_0_30_, primaryind2_.CompanyId as CompanyId32_, primaryind2_.CompanyIndustryId as CompanyI1_32_, primaryind2_.CompanyIndustryId as CompanyI1_8_0_, primaryind2_.IsPrimary as IsPrimary8_0_, primaryind2_.CompanyId as CompanyId8_0_, primaryind2_.HIC 作为 HIC8_0_、industry3_.HIC 作为 HIC6_1_、industry3_.Name 作为 Name6_1_、industry3_.Level 作为 Level6_1_、industry3_。ParentHIC as ParentHIC6_1_, itspending4_.CompanyId as CompanyId33_, itspending4_.ITSpendingId as ITSpendi1_33_, itspending4_.ITSpendingId as ITSpendi1_14_2_, itspending4_.Amount as Amount14_2_, itspending4_.CompanyId as CompanyId14_2_, itspending4_.ITSpendingTypeId as ITSpendi3_14_2_, itspending5_.ITSpendingTypeID as ITSpendi1_15_3_, itspending5_.Name as Name15_3_, itspending5_.ParentID 作为 ParentID15_3_, hardware6_.CompanyId 作为 CompanyId34_, hardware6_.ITSpendingId 作为 ITSpendi1_34_, hardware6_.ITSpendingId 作为 ITSpendi1_14_4_, hardware6_.Amount 作为 Amount14_4_, hardware6_.CompanyId 作为 CompanyId14_4_, hardware6_.ITSpendingType4_35 作为 ITSpendi_35 计算_,_pendi3_1计算p7_.ITSpendingId 作为ITSpendi1_35_,计算p7_.ITSpendingId 作为ITSpendi1_14_5_,计算p7_.Amount 作为Amount14_5_,计算p7_。CompanyId as CompanyId14_5_, computingp7_.ITSpendingTypeId as ITSpendi3_14_5_, networking8_.CompanyId as CompanyId36_, networking8_.ITSpendingId as ITSpendi1_36_, networking8_.ITSpendingId as ITSpendi1_14_6_, networking8_.Amount as Amount14_6_, networking8_.CompanyId as CompanyId14_6_, networking8_.ITSpendingTypeId as ITSpendi3_14_6_, serversand9_.CompanyId as CompanyId37_, serversand9_.ITSpendingId as ITSpendi1_37_, serversand9_.ITSpendingId as ITSpendi1_14_7_, serversand9_.Amount as Amount14_7_, serversand9_.CompanyId as CompanyId14_7_, serversand9_.ITSpendingTypeId as ITSpendi3_14_7_, software10_.CompanyId as CompanyId38_, software10_.ITSpendingId as ITSpendi1_38_, software10_.ITSpendingId as ITSpendi1_14_8_, software10_.Amount 作为 Amount14_8_,software10_.CompanyId 作为 CompanyId14_8_,software10_。ITSpendingTypeId as ITSpendi3_14_8_, softwareli11_.CompanyId as CompanyId39_, softwareli11_.ITSpendingId as ITSpendi1_39_, softwareli11_.ITSpendingId as ITSpendi1_14_9_, softwareli11_.Amount as Amount14_9_, softwareli11_.CompanyId as CompanyId14_9_, softwareli11_.ITSpendingTypeId as ITSpendi3_14_9_, supportand12_.CompanyId as CompanyId40_, supportand12_.ITSpendingId as ITSpendi1_40_, supportand12_.ITSpendingId as ITSpendi1_14_10_, supportand12_.Amount as Amount14_10_, supportand12_.CompanyId as CompanyId14_10_, supportand12_.ITSpendingTypeId as ITSpendi3_14_10_, services13_.CompanyId as CompanyId41_, services13_.ITSpendingId as ITSpendi1_41_, services13_.ITSpendingId as ITSpendi1_14_11_, services13_.Amount as Amount14_11_, services13_.CompanyId 作为 CompanyId14_11_,services13_.ITSpendingTypeId 作为 ITSpending3_14_11_,applicatio14_.CompanyId as CompanyId42_, applicatio14_.ITSpendingId as ITSpendi1_42_, applicatio14_.ITSpendingId as ITSpendi1_14_12_, applicatio14_.Amount as Amount14_12_, applicatio14_.CompanyId as CompanyId14_12_, applicatio14_.ITSpendingTypeId as ITSpendi3_14_12_, infrastruc15_.CompanyId as CompanyId43_, infrastruc15_.ITSpendingId as ITSpendi1_43_, infrastruc15_. ITSpendingId as ITSpendi1_14_13_, infrastruc15_.Amount as Amount14_13_, infrastruc15_.CompanyId as CompanyId14_13_, infrastruc15_.ITSpendingTypeId as ITSpendi3_14_13_, helpdeskan16_.CompanyId as CompanyId44_, helpdeskan16_.ITSpendingId as ITSpendi1_44_, helpdeskan16_.ITSpendingId as ITSpendi1_14_14_, helpdeskan16_.Amount as Amount14_14_, helpdeskan16_.CompanyId as CompanyId14_14_、helpdeskan16_.ITSpendingTypeId 为 ITSpending3_14_14_、communiccat17_。CompanyId as CompanyId45_, communicat17_.ITSpendingId as ITSpendi1_45_, communicat17_.ITSpendingId as ITSpendi1_14_15_, communicat17_.Amount as Amount14_15_, communicat17_.CompanyId as CompanyId14_15_, communicat17_.ITSpendingTypeId as ITSpendi3_14_15_, voiceservi18_.CompanyId as CompanyId46_, voiceservi18_.ITSpendingId as ITSpendi1_46_, voiceservi18_.ITSpendingId as ITSpendi1_14_16_, voiceservi18_.Amount as Amount14_16_, voiceservi18_.CompanyId as CompanyId14_16_, voiceservi18_.ITSpendingTypeId as ITSpendi3_14_16_, dataservic19_.CompanyId as CompanyId47_, dataservic19_.ITSpendingId as ITSpendi1_47_, dataservic19_.ITSpendingId as ITSpendi1_14_17_, dataservic19_.Amount as Amount14_17_, dataservic19_.CompanyId as CompanyId14_17_, dataservic19_.ITSpendingTypeId 作为 ITSpendi3_14_17_,convergeds20_.CompanyId 作为 CompanyId48_,convergeds20_.ITSpendingId as ITSpendi1_48_, convergeds20_.ITSpendingId as ITSpendi1_14_18_, convergeds20_.Amount as Amount14_18_, convergeds20_.CompanyId as CompanyId14_18_, convergeds20_.ITSpendingTypeId as ITSpendi3_14_18_, consulting21_.CompanyId as CompanyId49_, consulting21_.ITSpendingId as ITSpendi1_49_, consulting21_.ITSpendingId as ITSpendi1_14_19_, consulting21_. Amount as Amount14_19_, consulting21_.CompanyId as CompanyId14_19_, consulting21_.ITSpendingTypeId as ITSpendi3_14_19_, systemspla22_.CompanyId as CompanyId50_, systemspla22_.ITSpendingId as ITSpendi1_50_, systemspla22_.ITSpendingId as ITSpendi1_14_20_, systemspla22_.Amount as Amount14_20_, systemspla22_.CompanyId as CompanyId14_20_, systemspla22_.ITSpendingTypeId as ITSpendi3_14_20_,disasterre23_.CompanyId 为 CompanyId51_,disasterre23_。ITSpendingId as ITSpendi1_51_, disasterre23_.ITSpendingId as ITSpendi1_14_21_, disasterre23_.Amount as Amount14_21_, disasterre23_.CompanyId as CompanyId14_21_, disasterre23_.ITSpendingTypeId as ITSpendi3_14_21_, traininged24_.CompanyId as CompanyId52_, traininged24_.ITSpendingId as ITSpendi1_52_, traininged24_.ITSpendingId as ITSpendi1_14_22_, traininged24_.Amount as Amount14_22_, traininged24_.CompanyId as CompanyId14_22_, traininged24_.ITSpendingTypeId as ITSpendi3_14_22_, internalit25_.CompanyId as CompanyId53_, internalit25_.ITSpendingId as ITSpendi1_53_, internalit25_.ITSpendingId as ITSpendi1_14_23_, internalit25_.Amount as Amount14_23_, internalit25_.CompanyId as CompanyId14_23_, internalit25_.ITSpendingTypeId as ITSpendi3_14_23_, telco26_.CompanyId 作为 CompanyId54_,telco26_.ITSpendingId 作为 ITSpendi1_54_,telco26_。ITSpendingId as ITSpendi1_14_24_, telco26_.Amount as Amount14_24_, telco26_.CompanyId as CompanyId14_24_, telco26_.ITSpendingTypeId as ITSpendi3_14_24_, systemsint27_.CompanyId as CompanyId55_, systemsint27_.ITSpendingId as ITSpendi1_55_, systemsint27_.ITSpendingId as ITSpendi1_14_25_, systemsint27_.Amount as Amount14_25_, systemsint27_.CompanyId as CompanyId14_25_, systemsint27_.ITSpendingTypeId as ITSpendi3_14_25_, zipcode28_.ZipCodeId as ZipCodeId27_26_, zipcode28_.ZipCode as ZipCode27_26_, siccode29_.Code as Code20_27_, siccode29_.Name as Name20_27_, country30_.CountryId as CountryId4_28_, country30_.Name as Name4_28_, country30_.GeographyId as Geograph3_4_28_, contracta31_.CompanyId 作为 CompanyId3_29_,contracta31_.ActiveContractValue 作为 ActiveCo2_3_29_,contracta31_.ActiveContractVolume 作为 ActiveCo3_3_29_,合同a31_.TotalContractValue 作为TotalCon4_3_29_,合同a31_.TotalContractVolume 作为TotalCon5_3_29_,合同a31_.RelationshipVendor 作为Relation6_3_29_ FROM 公司this_ 离开外部加入CompanyIndustry primaryind2_ on this_.CompanyId=primaryind2_.CompanyId 和(primaryind2_.IsPrimary = 1) 离开主要外部加入Hoovers.Industry33_ =industry3_.HIC 左外连接 ITSpending itspending4_ on this_.CompanyId=itspending4_.CompanyId 左外连接 ITSpendingType itspending5_ on itspending4_.ITSpendingTypeId=itspending5_.ITSpendingTypeID 左外连接 ITSpending hardware6_ on this_.CompanyId=hardware6_.CompanyId 和 (hardware6_.ITSpendingTypeId = 2 ) 在 this_.CompanyId=computingp7_.CompanyId 和 (computingp7_.ITSpendingTypeId = 12) 在 this_.CompanyId=networking8_.CompanyId 和 (networking8_.ITSpendingTypeId = 11) 左外连接 ITSpending 网络 8_.CompanyId=serversand9_.CompanyId 和 (serversand9_.ITSpendingTypeId = 10) 左外连接 ITSpending 服务器和 9_ software10_ on this_.CompanyId=software10_.CompanyId 和 (software10_.ITSpendingTypeId = 3) 左外连接 ITSpending softwareli11_ on this_.CompanyId=softwareli11_.CompanyId 和 (softwareli11_.ITSpendingTypeId = 15) 左外连接 ITSpending supportand12_ on this_.CompanyId=supportand12_。 CompanyId 和 (supportand12_.ITSpendingTypeId = 16) 在 this_.CompanyId=services13_.CompanyId 上左外连接 ITSpending services13_ 和 (services13_.ITSpendingTypeId = 4) 在 this_.CompanyId=application14_ 上左外连接 ITSpending applicatio14_。CompanyId 和 (application14_.ITSpendingTypeId = 19) 左外连接 ITSpending infrastruc15_ on this_.CompanyId=infrastruc15_.CompanyId 和 (infrastruc15_.ITSpendingTypeId = 20) 左外连接 ITSpending helpdeskan16_ on this_.CompanyId=helpdeskan16_.CompanyId 和 (helpdeskan16_.ITSpendingTypeId = 21 ) 在 this_.CompanyId=communicat17_.CompanyId 和 (communicat17_.ITSpendingTypeId = 5) 在 this_.CompanyId=voiceservi18_.CompanyId 和 (voiceservi18_.ITSpendingTypeId = 24) 上的左外连接 ITSpending dataservic19_ 上左外连接.CompanyId=dataservic19_.CompanyId 和 (dataservic19_.ITSpendingTypeId = 25) 在 this_.CompanyId=convergeds20_.CompanyId 和 (convergeds20_.ITSpendingTypeId = 26) 在 this_.CompanyId=consulting21_.CompanyId 和 (consulting21_.ITSpendingTypeId = 6) 上左外连接 ITSpending在this_.CompanyId=disasterre23_.CompanyId 上的disasterre23_ 和(disasterre23_.ITSpendingTypeId = 30)在this_.CompanyId=traininged24_.CompanyId 上左外连接ITSpending traininged24_和(traininged24_.ITSpendingTypeId = 31)在this_.CompanyId=internalit25_上左外连接ITSpending internalit25_。 CompanyId 和 (internalit25_.ITSpendingTypeId = 38) 左外连接 ITSpending telco26_ on this_.CompanyId=telco26_.CompanyId 和 (telco26_.ITSpendingTypeId = 35) 左外连接 ITSpending systemsint27_ on this_。CompanyId=systemsint27_.CompanyId 和 (systemsint27_.ITSpendingTypeId = 36) 左外连接 ZipCode zipcode28_ on this_.ZipCodeId=zipcode28_.ZipCodeId 左外连接 SICCode siccode29_ on this_.PrimarySIC_Code=siccode29_.Code 左外连接 Country country30_ on this_.CountryId=country30_ .CountryId 左外连接 CompanyContractAggregation contracta31_ on this_.CompanyId=contractsa31_.CompanyId WHERE this_.CompanyId in (@p0)]] NHibernate.Loader.Loader.DoList(ISessionImplementor session, QueryParameters queryParameters) +637CountryId 左外连接 CompanyContractAggregation contracta31_ on this_.CompanyId=contractsa31_.CompanyId WHERE this_.CompanyId in (@p0)]] NHibernate.Loader.Loader.DoList(ISessionImplementor session, QueryParameters queryParameters) +637CountryId 左外连接 CompanyContractAggregation contracta31_ on this_.CompanyId=contractsa31_.CompanyId WHERE this_.CompanyId in (@p0)]] NHibernate.Loader.Loader.DoList(ISessionImplementor session, QueryParameters queryParameters) +637
NHibernate.Loader.Loader.ListIgnoreQueryCache(ISessionImplementor session, QueryParameters queryParameters) +23
NHibernate.Loader.Criteria.CriteriaLoader.List(ISessionImplementor session) +60 NHibernate.Impl.SessionImpl.List(CriteriaImpl criteria, IList results) +1025
NHibernate.Impl .CriteriaImpl.List(IList 结果) +63
NHibernate.Impl.CriteriaImpl.List() +79
Ovum.Ictop.Dal.CustomRepositories.CompanyRepository.Criteria(CriteriaInstance 标准, Nullable1 pageIndex, Nullable
1 pageSize, Nullable1 maxCount) in c:\GIT-ICTOP\Ovum_Ictop\Ovum.Ictop.Admin.Dal\CustomRepositories\CompanyRepository.cs:69 Ovum.Ictop.Bl.ServiceWrappers.CompanyService.GetCompanyByCriteria(CriteriaInstance criteria, Nullable
1 pageIndex, Nullable1 pageSize, Nullable
1 maxCount) 在 c:\GIT-ICTOP\Ovum_Ictop\Ovum.Ictop.Bl\ServiceWrappers\CompanyService.cs:289 Ovum.Ictop.Web.Areas.CA.Controllers.SearchController.GetCompanyByLikeName(String name, Int32 numberPage) 在 c :\GIT-ICTOP\Ovum_Ictop\Ovum.Ictop.Web\Areas\CA\Controllers\SearchController.cs:45 Ovum.Ictop.Web.Areas.CA.Controllers.SearchController.Search(String companyName) in c:\GIT- ICTOP\Ovum_Ictop\Ovum.Ictop.Web\Areas\CA\Controllers\SearchController.cs:29 lambda_method(Closure, ControllerBase, Object[]) +127
System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary 2 参数) +39 System.Web.Mvc.<>c_ DisplayClass15.<InvokeActionMethodWithFilters>b2 parameters) +264
System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary
_12() +129 System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter filter, ActionExecutingContext preContext, Func1 continuation) +826106 System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodWithFilters(ControllerContext controllerContext, IList
1 filters, ActionDescriptor actionDescriptor, IDictionary`2 参数) +314
System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName ) +825328
System.Web.Mvc.Controller.ExecuteCore( ) +159 System.Web.Mvc.ControllerBase.Execute(
RequestContext requestContext) +335 System.Web.Mvc.<>c_DisplayClassb .<BeginProcessRequest>b _5() + 62 System.Web.Mvc.Async.<> c_DisplayClass1.<MakeVoidDelegate>b _0() +20 System.Web.Mvc.<>c_DisplayClasse .<EndProcessRequest>b_d() +54 System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +469 System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +375
sql - DB2 Statistical View 对基数估计没有影响
我有一张桌子,我们称之为它ACTIONS
,它有大约 1100 万行。其中一列 ,ACTION_DATE
说明了这件事发生的时间。我想生成一份关于昨天采取的行动的每日报告,但有时我想生成一份很久以前的报告。该表包含大约 3 年前的数据。
列上的分布ACTION_DATE
非常倾斜。有时一天会有超过 50k 的动作,而其他日子只有几百个。我RUNSTATS
在这张表上做了一个,它很快用过去几年的条目填充它的频率列表,这导致 db2 错误地计算了访问该表的成本并导致执行计划错误。
我已阅读有关统计视图的信息,并认为这可能有助于解决问题。所以我做了一个这样的:
但它似乎对成本估算或查询计划没有影响。
另一方面,如果我手动将特定日期的基数插入SYSSTAT
表中:
并解释当天查询的访问计划,我看到它会获取信息并相应地调整成本。
我的统计视图有什么问题?
c# - SqlServer 中的慢速选择查询从表中返回 6000 万条记录中的 1300 万条记录
我们有一个包含大约 25 列的表,其中包括一个 TXT_SUBSCRIBER_CELL_ID 和 LNGCASE_ID,我们在其上创建了组合索引。
当我们查询
完成执行大约需要 50-55 秒,这非常慢。
我们怎样才能让它跑得快。
php - 使用多个连接进行查询
我现在正在学习 php 和 codeigniter,现在我想结合查询来快速有效。我已经做了所有,但还没有加入最后一张桌子......
我有 4 个表:posts、users、post_categories、categories;
我想得到什么:
- 所有帖子
- 使用 usr_id 的用户信息
- 使用 cat_ids 从 post_categories 获取所有类别 id
- 并使用 id_* 获取每个类别的名称
这就是我最终的结果......它并不完整,因为我一直坚持为每个 id_* 获取类别名称
任何人都可以帮助我在codeigniter中结束这个查询吗?
编辑: 在 post_categories 中:id_1 总是......但 id_2 和 id_3 可以保持为 NULL(默认值)
php - 如何加速 codeigniter/php 分页,sql-query
编辑: usr_id,cat_ids,活动,id_1,id_2,id_3 => 索引。当然,所有 id 都是主键这是我的 SQL 表,以及我使用 codeigniter 进行的查询:
也是控制器:
那么我怎样才能加快所有这些分页的东西......因为当有 1,5k 页(15000 个帖子)时,它会减慢速度......我想我能提供的所有信息,但我可以自由地询问更多信息
sql - SQL Server 分页查询 - 性能注意事项
我正在研究 SQL,并且在性能方面不是那么技术性。我正在使用 c# 动态形成查询,并且在我的脑海中具有分页目的
每次在分页上单击时,我都会获取 10 条记录和我的示例查询,如下所示
其中 testId 是主键。
效果很好。我发布了语法,因为它是机密数据。它在 6 秒内执行
如果用户点击最后一页形成以下查询
上述查询需要 40 秒。
我缺少的核心是什么
每次我得到 10 条记录,但时间差异很大
谢谢
sql - 不等于性能
!=
和之间的性能有区别<>
吗?
奖励:为什么当我使用!=
而不是时人们会感到不安<>
?我当然推测所有程序员都会对此感到不安,但是我现在已经为两家“要求”使用<>
c# - 参数化 Linq to SQL 查询导致性能问题
我有一个 linq 查询需要 11 分钟才能针对 MSSQL server 2008 执行。我使用 MSSQL Profiler 来查找执行时间很长的查询,然后我将它单独运行到我的数据库中。
我还删除了所有参数并直接添加了值并运行了查询。执行时间不到 1 秒!
我搜索了一下,发现使用参数确实会影响性能,因为计划是在 where 子句的值已知之前编译的。
由于 Linq to SQL 总是运行参数化 SQL,在这种情况下我可以做些什么来提高性能?
我还没有发现任何可以改进的关于索引的列。Inner Join 语句中的第一个表有 192 014 行,不带参数的 SQL 执行时间不到一秒。附上执行计划的截图。
编辑在屏幕截图下方。
这是 Linq 查询:
编辑:这里的屏幕截图确实有点小。参数化 SQL 中只有 5 个参数。
编辑2:是带有参数@p0 的Inner Join 语句导致执行计划发生变化。当我只删除带有值本身的@p0 变量时,它会在不到一秒的时间内运行。如果此值在所有情况下都是恒定的(我必须对此进行调查),我可以做任何事情以使该值不会像参数一样被使用吗?