- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我们有两个 Web 应用程序在同一个数据库上工作的情况。它们都使用 TransactionScope(在 c# 中)来封装导入例程。
我们从每个事务范围内的两个语句中得到一个死锁。第一个是:
DELETE FROM Period WHERE CompanyId = 72
insert bulk Amount ([AccountId] Int, [PeriodId] Int, [Value] Decimal(18,2)) with (CHECK_CONSTRAINTS)
<deadlock-list>
<deadlock victim="process7373048">
<process-list>
<process id="process7373048" taskpriority="0" logused="53608" waitresource="KEY: 5:72057594040811520 (55caf8cfebcf)" waittime="262" ownerId="21707350" transactionname="user_transaction" lasttranstarted="2011-11-11T14:26:47.660" XDES="0x72af950" lockMode="U" schedulerid="1" kpid="1212" status="suspended" spid="57" sbid="2" ecid="0" priority="0" trancount="2" lastbatchstarted="2011-11-11T14:26:49.273" lastbatchcompleted="2011-11-11T14:26:49.273" clientapp=".Net SqlClient Data Provider" hostname="Fathom-1" hostpid="3396" loginname="fathom_WebUser" isolationlevel="read committed (2)" xactid="21707350" currentdb="5" lockTimeout="4294967295" clientoption1="671088672" clientoption2="128056">
<executionStack>
<frame procname="adhoc" line="1" sqlhandle="0x02000000bbf5661cad04d2a71e72d51fe7835afad57a3259">
DELETE FROM Period WHERE CompanyId = 105 AND Type = 7 AND DateRangeId IN (
SELECT Id
FROM DateRange
WHERE Start >= '20110101 00:00:00') </frame>
</executionStack>
<inputbuf>
DELETE FROM Period WHERE CompanyId = 105 AND Type = 7 AND DateRangeId IN (
SELECT Id
FROM DateRange
WHERE Start >= '20110101 00:00:00') </inputbuf>
</process>
<process id="process2c37e508" taskpriority="0" logused="570716" waitresource="KEY: 5:72057594040352768 (a559124170e7)" waittime="1330" ownerId="21707151" transactionname="user_transaction" lasttranstarted="2011-11-11T14:26:46.640" XDES="0x7207950" lockMode="S" schedulerid="1" kpid="3068" status="suspended" spid="58" sbid="2" ecid="0" priority="0" trancount="2" lastbatchstarted="2011-11-11T14:26:48.203" lastbatchcompleted="2011-11-11T14:26:48.203" clientapp=".Net SqlClient Data Provider" hostname="Fathom-1" hostpid="3396" loginname="fathom_WebUser" isolationlevel="read committed (2)" xactid="21707151" currentdb="5" lockTimeout="4294967295" clientoption1="671088672" clientoption2="128056">
<executionStack>
<frame procname="adhoc" line="1" sqlhandle="0x020000001672aa048fceb23bce7f8c54178cbbe497dba1a6">
insert bulk Amount ([AccountId] Int, [PeriodId] Int, [Value] Decimal(18,2)) with (CHECK_CONSTRAINTS) </frame>
</executionStack>
<inputbuf>
insert bulk Amount ([AccountId] Int, [PeriodId] Int, [Value] Decimal(18,2)) with (CHECK_CONSTRAINTS) </inputbuf>
</process>
</process-list>
<resource-list>
<keylock hobtid="72057594040811520" dbid="5" objectname="fathom.dbo.Period" indexname="PK_Period" id="lock2ab24500" mode="X" associatedObjectId="72057594040811520">
<owner-list>
<owner id="process2c37e508" mode="X"/>
</owner-list>
<waiter-list>
<waiter id="process7373048" mode="U" requestType="wait"/>
</waiter-list>
</keylock>
<keylock hobtid="72057594040352768" dbid="5" objectname="fathom.dbo.Account" indexname="PK_Account" id="lock1ce65980" mode="X" associatedObjectId="72057594040352768">
<owner-list>
<owner id="process7373048" mode="X"/>
</owner-list>
<waiter-list>
<waiter id="process2c37e508" mode="S" requestType="wait"/>
</waiter-list>
</keylock>
</resource-list>
</deadlock>
</deadlock-list>
<ShowPlanXML xmlns="http://schemas.microsoft.com/sqlserver/2004/07/showplan" Version="1.1" Build="10.50.2500.0"><BatchSequence><Batch><Statements><StmtSimple><QueryPlan CachedPlanSize="40" CompileTime="4" CompileCPU="4" CompileMemory="288"><RelOp NodeId="1" PhysicalOp="Assert" LogicalOp="Assert" EstimateRows="8100" EstimateIO="0" EstimateCPU="0.005508" AvgRowSize="9" EstimatedTotalSubtreeCost="4.81146" Parallel="0" EstimateRebinds="0" EstimateRewinds="0"><OutputList/><Assert StartupExpression="0"><RelOp NodeId="2" PhysicalOp="Merge Join" LogicalOp="Left Semi Join" EstimateRows="8100" EstimateIO="0.025979" EstimateCPU="0.0311493" AvgRowSize="9" EstimatedTotalSubtreeCost="4.80595" Parallel="0" EstimateRebinds="0" EstimateRewinds="0"><OutputList><ColumnReference Column="Expr1012"/><ColumnReference Column="Expr1013"/></OutputList><Merge ManyToMany="1"><InnerSideJoinColumns><ColumnReference Database="[fathom]" Schema="[dbo]" Table="[Period]" Column="Id"/></InnerSideJoinColumns><OuterSideJoinColumns><ColumnReference Database="[fathom]" Schema="[dbo]" Table="[Amount]" Column="PeriodId"/></OuterSideJoinColumns><Residual><ScalarOperator ScalarString="[fathom].[dbo].[Amount].[PeriodId]=[fathom].[dbo].[Period].[Id]"><Compare CompareOp="EQ"><ScalarOperator><Identifier><ColumnReference Database="[fathom]" Schema="[dbo]" Table="[Amount]" Column="PeriodId"/></Identifier></ScalarOperator><ScalarOperator><Identifier><ColumnReference Database="[fathom]" Schema="[dbo]" Table="[Period]" Column="Id"/></Identifier></ScalarOperator></Compare></ScalarOperator></Residual><RelOp NodeId="3" PhysicalOp="Sort" LogicalOp="Sort" EstimateRows="9000" EstimateIO="0.0112613" EstimateCPU="0.465821" AvgRowSize="12" EstimatedTotalSubtreeCost="4.74537" Parallel="0" EstimateRebinds="0" EstimateRewinds="0"><OutputList><ColumnReference Database="[fathom]" Schema="[dbo]" Table="[Amount]" Column="PeriodId"/><ColumnReference Column="Expr1012"/></OutputList><MemoryFractions Input="0.42446" Output="1"/><Sort Distinct="0"><OrderBy><OrderByColumn Ascending="1"><ColumnReference Database="[fathom]" Schema="[dbo]" Table="[Amount]" Column="PeriodId"/></OrderByColumn></OrderBy><RelOp NodeId="4" PhysicalOp="Merge Join" LogicalOp="Left Semi Join" EstimateRows="9000" EstimateIO="0.027857" EstimateCPU="0.0353131" AvgRowSize="12" EstimatedTotalSubtreeCost="4.26829" Parallel="0" EstimateRebinds="0" EstimateRewinds="0"><OutputList><ColumnReference Database="[fathom]" Schema="[dbo]" Table="[Amount]" Column="PeriodId"/><ColumnReference Column="Expr1012"/></OutputList><Merge ManyToMany="1"><InnerSideJoinColumns><ColumnReference Database="[fathom]" Schema="[dbo]" Table="[Account]" Column="Id"/></InnerSideJoinColumns><OuterSideJoinColumns><ColumnReference Database="[fathom]" Schema="[dbo]" Table="[Amount]" Column="AccountId"/></OuterSideJoinColumns><Residual><ScalarOperator ScalarString="[fathom].[dbo].[Amount].[AccountId]=[fathom].[dbo].[Account].[Id]"><Compare CompareOp="EQ"><ScalarOperator><Identifier><ColumnReference Database="[fathom]" Schema="[dbo]" Table="[Amount]" Column="AccountId"/></Identifier></ScalarOperator><ScalarOperator><Identifier><ColumnReference Database="[fathom]" Schema="[dbo]" Table="[Account]" Column="Id"/></Identifier></ScalarOperator></Compare></ScalarOperator></Residual><RelOp NodeId="5" PhysicalOp="Clustered Index Insert" LogicalOp="Insert" EstimateRows="10000" EstimateIO="0.201195" EstimateCPU="0.01" AvgRowSize="15" EstimatedTotalSubtreeCost="4.19121" Parallel="0" EstimateRebinds="0" EstimateRewinds="0"><OutputList><ColumnReference Database="[fathom]" Schema="[dbo]" Table="[Amount]" Column="AccountId"/><ColumnReference Database="[fathom]" Schema="[dbo]" Table="[Amount]" Column="PeriodId"/></OutputList><Update DMLRequestSort="1"><Object Database="[fathom]" Schema="[dbo]" Table="[Amount]" Index="[PK_Amount]" IndexKind="Clustered"/><SetPredicate><ScalarOperator ScalarString="[fathom].[dbo].[Amount].[AccountId] = RaiseIfNullInsert([!BulkInsert].[AccountId]),[fathom].[dbo].[Amount].[PeriodId] = RaiseIfNullInsert([!BulkInsert].[PeriodId]),[fathom].[dbo].[Amount].[Value] = RaiseIfNullInsert([Expr1005])"><ScalarExpressionList><ScalarOperator><MultipleAssign><Assign><ColumnReference Database="[fathom]" Schema="[dbo]" Table="[Amount]" Column="AccountId"/><ScalarOperator><Intrinsic FunctionName="RaiseIfNullInsert"><ScalarOperator><Identifier><ColumnReference Table="[!BulkInsert]" Column="AccountId"/></Identifier></ScalarOperator></Intrinsic></ScalarOperator></Assign><Assign><ColumnReference Database="[fathom]" Schema="[dbo]" Table="[Amount]" Column="PeriodId"/><ScalarOperator><Intrinsic FunctionName="RaiseIfNullInsert"><ScalarOperator><Identifier><ColumnReference Table="[!BulkInsert]" Column="PeriodId"/></Identifier></ScalarOperator></Intrinsic></ScalarOperator></Assign><Assign><ColumnReference Database="[fathom]" Schema="[dbo]" Table="[Amount]" Column="Value"/><ScalarOperator><Intrinsic FunctionName="RaiseIfNullInsert"><ScalarOperator><Identifier><ColumnReference Column="Expr1005"/></Identifier></ScalarOperator></Intrinsic></ScalarOperator></Assign></MultipleAssign></ScalarOperator></ScalarExpressionList></ScalarOperator></SetPredicate><RelOp NodeId="6" PhysicalOp="Sort" LogicalOp="Sort" EstimateRows="10000" EstimateIO="0.0112613" EstimateCPU="0.60342" AvgRowSize="24" EstimatedTotalSubtreeCost="3.98001" Parallel="0" EstimateRebinds="0" EstimateRewinds="0"><OutputList><ColumnReference Table="[!BulkInsert]" Column="AccountId"/><ColumnReference Table="[!BulkInsert]" Column="PeriodId"/><ColumnReference Column="Expr1005"/></OutputList><MemoryFractions Input="1" Output="0.57554"/><Sort Distinct="0"><OrderBy><OrderByColumn Ascending="1"><ColumnReference Table="[!BulkInsert]" Column="AccountId"/></OrderByColumn><OrderByColumn Ascending="1"><ColumnReference Table="[!BulkInsert]" Column="PeriodId"/></OrderByColumn></OrderBy><RelOp NodeId="7" PhysicalOp="Compute Scalar" LogicalOp="Compute Scalar" EstimateRows="10000" EstimateIO="0" EstimateCPU="0.001" AvgRowSize="24" EstimatedTotalSubtreeCost="3.36533" Parallel="0" EstimateRebinds="0" EstimateRewinds="0"><OutputList><ColumnReference Table="[!BulkInsert]" Column="AccountId"/><ColumnReference Table="[!BulkInsert]" Column="PeriodId"/><ColumnReference Column="Expr1005"/></OutputList><ComputeScalar><DefinedValues><DefinedValue><ColumnReference Column="Expr1005"/><ScalarOperator ScalarString="CONVERT_IMPLICIT(decimal(18,2),[!BulkInsert].[Value],0)"><Convert DataType="decimal" Precision="18" Scale="2" Style="0" Implicit="1"><ScalarOperator><Identifier><ColumnReference Table="[!BulkInsert]" Column="Value"/></Identifier></ScalarOperator></Convert></ScalarOperator></DefinedValue></DefinedValues><RelOp NodeId="8" PhysicalOp="Top" LogicalOp="Top" EstimateRows="10000" EstimateIO="0" EstimateCPU="0.001" AvgRowSize="24" EstimatedTotalSubtreeCost="3.36433" Parallel="0" EstimateRebinds="0" EstimateRewinds="0"><OutputList><ColumnReference Table="[!BulkInsert]" Column="AccountId"/><ColumnReference Table="[!BulkInsert]" Column="PeriodId"/><ColumnReference Table="[!BulkInsert]" Column="Value"/></OutputList><Top RowCount="1" IsPercent="0" WithTies="0"><TopExpression><ScalarOperator ScalarString="(0)"><Const ConstValue="(0)"/></ScalarOperator></TopExpression><RelOp NodeId="9" PhysicalOp="Remote Scan" LogicalOp="Remote Scan" EstimateRows="10000" EstimateIO="0" EstimateCPU="3.36333" AvgRowSize="24" EstimatedTotalSubtreeCost="3.36333" Parallel="0" EstimateRebinds="0" EstimateRewinds="0"><OutputList><ColumnReference Table="[!BulkInsert]" Column="AccountId"/><ColumnReference Table="[!BulkInsert]" Column="PeriodId"/><ColumnReference Table="[!BulkInsert]" Column="Value"/></OutputList><RemoteScan RemoteObject="STREAM"/></RelOp></Top></RelOp></ComputeScalar></RelOp></Sort></RelOp></Update></RelOp><RelOp NodeId="14" PhysicalOp="Clustered Index Scan" LogicalOp="Clustered Index Scan" EstimateRows="907" EstimateIO="0.0127546" EstimateCPU="0.0011547" AvgRowSize="11" EstimatedTotalSubtreeCost="0.0139093" TableCardinality="907" Parallel="0" EstimateRebinds="0" EstimateRewinds="0"><OutputList><ColumnReference Database="[fathom]" Schema="[dbo]" Table="[Account]" Column="Id"/></OutputList><IndexScan Ordered="1" ScanDirection="FORWARD" ForcedIndex="1" ForceSeek="0" ForceScan="0" NoExpandHint="0"><DefinedValues><DefinedValue><ColumnReference Database="[fathom]" Schema="[dbo]" Table="[Account]" Column="Id"/></DefinedValue></DefinedValues><Object Database="[fathom]" Schema="[dbo]" Table="[Account]" Index="[PK_Account]" IndexKind="Clustered"/></IndexScan></RelOp></Merge></RelOp></Sort></RelOp><RelOp NodeId="16" PhysicalOp="Clustered Index Scan" LogicalOp="Clustered Index Scan" EstimateRows="150" EstimateIO="0.003125" EstimateCPU="0.000322" AvgRowSize="11" EstimatedTotalSubtreeCost="0.003447" TableCardinality="150" Parallel="0" EstimateRebinds="0" EstimateRewinds="0"><OutputList><ColumnReference Database="[fathom]" Schema="[dbo]" Table="[Period]" Column="Id"/></OutputList><IndexScan Ordered="1" ScanDirection="FORWARD" ForcedIndex="1" ForceSeek="0" ForceScan="0" NoExpandHint="0"><DefinedValues><DefinedValue><ColumnReference Database="[fathom]" Schema="[dbo]" Table="[Period]" Column="Id"/></DefinedValue></DefinedValues><Object Database="[fathom]" Schema="[dbo]" Table="[Period]" Index="[PK_Period]" IndexKind="Clustered"/></IndexScan></RelOp></Merge></RelOp><Predicate><ScalarOperator ScalarString="CASE WHEN [Expr1012] IS NULL THEN (0) ELSE CASE WHEN [Expr1013] IS NULL THEN (1) ELSE NULL END END"><IF><Condition><ScalarOperator><Logical Operation="IS NULL"><ScalarOperator><Identifier><ColumnReference Column="Expr1012"/></Identifier></ScalarOperator></Logical></ScalarOperator></Condition><Then><ScalarOperator><Const ConstValue="(0)"/></ScalarOperator></Then><Else><ScalarOperator><IF><Condition><ScalarOperator><Logical Operation="IS NULL"><ScalarOperator><Identifier><ColumnReference Column="Expr1013"/></Identifier></ScalarOperator></Logical></ScalarOperator></Condition><Then><ScalarOperator><Const ConstValue="(1)"/></ScalarOperator></Then><Else><ScalarOperator><Const ConstValue="NULL"/></ScalarOperator></Else></IF></ScalarOperator></Else></IF></ScalarOperator></Predicate></Assert></RelOp></QueryPlan></StmtSimple></Statements></Batch></BatchSequence></ShowPlanXML>
<ShowPlanXML xmlns="http://schemas.microsoft.com/sqlserver/2004/07/showplan" Version="1.1" Build="10.50.2500.0"><BatchSequence><Batch><Statements><StmtSimple><QueryPlan CachedPlanSize="104" CompileTime="9" CompileCPU="9" CompileMemory="544"><MissingIndexes><MissingIndexGroup Impact="34.2748"><MissingIndex Database="[fathom]" Schema="[dbo]" Table="[Amount]"><ColumnGroup Usage="EQUALITY"><Column Name="[PeriodId]" ColumnId="2"/></ColumnGroup><ColumnGroup Usage="INCLUDE"><Column Name="[AccountId]" ColumnId="1"/></ColumnGroup></MissingIndex></MissingIndexGroup><MissingIndexGroup Impact="46.6451"><MissingIndex Database="[fathom]" Schema="[dbo]" Table="[Result]"><ColumnGroup Usage="EQUALITY"><Column Name="[PeriodId]" ColumnId="2"/></ColumnGroup><ColumnGroup Usage="INCLUDE"><Column Name="[MetricId]" ColumnId="1"/></ColumnGroup></MissingIndex></MissingIndexGroup></MissingIndexes><RelOp NodeId="1" PhysicalOp="Sequence" LogicalOp="Sequence" EstimateRows="119.191" EstimateIO="0" EstimateCPU="0.000233964" AvgRowSize="9" EstimatedTotalSubtreeCost="0.49074" Parallel="0" EstimateRebinds="0" EstimateRewinds="0"><OutputList/><Sequence><RelOp NodeId="2" PhysicalOp="Table Spool" LogicalOp="Eager Spool" EstimateRows="1" EstimateIO="0" EstimateCPU="2.54684e-005" AvgRowSize="11" EstimatedTotalSubtreeCost="0.00431261" Parallel="0" EstimateRebinds="0" EstimateRewinds="0"><OutputList><ColumnReference Database="[fathom]" Schema="[dbo]" Table="[Period]" Column="Id"/></OutputList><Spool><RelOp NodeId="3" PhysicalOp="Clustered Index Delete" LogicalOp="Delete" EstimateRows="1" EstimateIO="0.01" EstimateCPU="1e-006" AvgRowSize="11" EstimatedTotalSubtreeCost="0.01685" Parallel="0" EstimateRebinds="0" EstimateRewinds="0"><OutputList><ColumnReference Database="[fathom]" Schema="[dbo]" Table="[Period]" Column="Id"/></OutputList><Update DMLRequestSort="0"><Object Database="[fathom]" Schema="[dbo]" Table="[Period]" Index="[PK_Period]" IndexKind="Clustered"/><RelOp NodeId="4" PhysicalOp="Top" LogicalOp="Top" EstimateRows="1" EstimateIO="0" EstimateCPU="1e-007" AvgRowSize="11" EstimatedTotalSubtreeCost="0.00684904" Parallel="0" EstimateRebinds="0" EstimateRewinds="0"><OutputList><ColumnReference Database="[fathom]" Schema="[dbo]" Table="[Period]" Column="Id"/></OutputList><Top RowCount="1" IsPercent="0" WithTies="0"><TopExpression><ScalarOperator ScalarString="(0)"><Const ConstValue="(0)"/></ScalarOperator></TopExpression><RelOp NodeId="6" PhysicalOp="Nested Loops" LogicalOp="Inner Join" EstimateRows="1" EstimateIO="0" EstimateCPU="4.18e-006" AvgRowSize="11" EstimatedTotalSubtreeCost="0.00684894" Parallel="0" EstimateRebinds="0" EstimateRewinds="0"><OutputList><ColumnReference Database="[fathom]" Schema="[dbo]" Table="[Period]" Column="Id"/></OutputList><NestedLoops Optimized="0"><OuterReferences><ColumnReference Database="[fathom]" Schema="[dbo]" Table="[Period]" Column="DateRangeId"/></OuterReferences><RelOp NodeId="7" PhysicalOp="Clustered Index Scan" LogicalOp="Clustered Index Scan" EstimateRows="1" EstimateIO="0.003125" EstimateCPU="0.0003121" AvgRowSize="20" EstimatedTotalSubtreeCost="0.0034371" TableCardinality="141" Parallel="0" EstimateRebinds="0" EstimateRewinds="0"><OutputList><ColumnReference Database="[fathom]" Schema="[dbo]" Table="[Period]" Column="Id"/><ColumnReference Database="[fathom]" Schema="[dbo]" Table="[Period]" Column="DateRangeId"/></OutputList><IndexScan Ordered="1" ForcedIndex="0" ForceScan="0" NoExpandHint="0"><DefinedValues><DefinedValue><ColumnReference Database="[fathom]" Schema="[dbo]" Table="[Period]" Column="Id"/></DefinedValue><DefinedValue><ColumnReference Database="[fathom]" Schema="[dbo]" Table="[Period]" Column="DateRangeId"/></DefinedValue></DefinedValues><Object Database="[fathom]" Schema="[dbo]" Table="[Period]" Index="[PK_Period]" IndexKind="Clustered"/><Predicate><ScalarOperator ScalarString="[fathom].[dbo].[Period].[CompanyId]=(118) AND [fathom].[dbo].[Period].[Type]=(10)"><Logical Operation="AND"><ScalarOperator><Compare CompareOp="EQ"><ScalarOperator><Identifier><ColumnReference Database="[fathom]" Schema="[dbo]" Table="[Period]" Column="CompanyId"/></Identifier></ScalarOperator><ScalarOperator><Const ConstValue="(118)"/></ScalarOperator></Compare></ScalarOperator><ScalarOperator><Compare CompareOp="EQ"><ScalarOperator><Identifier><ColumnReference Database="[fathom]" Schema="[dbo]" Table="[Period]" Column="Type"/></Identifier></ScalarOperator><ScalarOperator><Const ConstValue="(10)"/></ScalarOperator></Compare></ScalarOperator></Logical></ScalarOperator></Predicate></IndexScan></RelOp><RelOp NodeId="8" PhysicalOp="Clustered Index Seek" LogicalOp="Clustered Index Seek" EstimateRows="1" EstimateIO="0.003125" EstimateCPU="0.0001581" AvgRowSize="10" EstimatedTotalSubtreeCost="0.0032831" TableCardinality="2554" Parallel="0" EstimateRebinds="0" EstimateRewinds="0"><OutputList/><IndexScan Ordered="1" ScanDirection="FORWARD" ForcedIndex="0" ForceSeek="0" ForceScan="0" NoExpandHint="0"><DefinedValues/><Object Database="[fathom]" Schema="[dbo]" Table="[DateRange]" Index="[PK_DateRange]" IndexKind="Clustered"/><SeekPredicates><SeekPredicateNew><SeekKeys><Prefix ScanType="EQ"><RangeColumns><ColumnReference Database="[fathom]" Schema="[dbo]" Table="[DateRange]" Column="Id"/></RangeColumns><RangeExpressions><ScalarOperator ScalarString="[fathom].[dbo].[Period].[DateRangeId]"><Identifier><ColumnReference Database="[fathom]" Schema="[dbo]" Table="[Period]" Column="DateRangeId"/></Identifier></ScalarOperator></RangeExpressions></Prefix></SeekKeys></SeekPredicateNew></SeekPredicates><Predicate><ScalarOperator ScalarString="[fathom].[dbo].[DateRange].[Start]>='2011-07-01'"><Compare CompareOp="GE"><ScalarOperator><Identifier><ColumnReference Database="[fathom]" Schema="[dbo]" Table="[DateRange]" Column="Start"/></Identifier></ScalarOperator><ScalarOperator><Const ConstValue="'2011-07-01'"/></ScalarOperator></Compare></ScalarOperator></Predicate></IndexScan></RelOp></NestedLoops></RelOp></Top></RelOp></Update></RelOp></Spool></RelOp><RelOp NodeId="11" PhysicalOp="Clustered Index Delete" LogicalOp="Delete" EstimateRows="107.939" EstimateIO="0.0116206" EstimateCPU="0.000107939" AvgRowSize="9" EstimatedTotalSubtreeCost="0.261311" Parallel="0" EstimateRebinds="0" EstimateRewinds="0"><OutputList/><Update DMLRequestSort="1"><Object Database="[fathom]" Schema="[dbo]" Table="[Result]" Index="[PK_RatioResult]" IndexKind="Clustered"/><RelOp NodeId="13" PhysicalOp="Sort" LogicalOp="Sort" EstimateRows="107.939" EstimateIO="0.0112613" EstimateCPU="0.0012373" AvgRowSize="19" EstimatedTotalSubtreeCost="0.249583" Parallel="0" EstimateRebinds="0" EstimateRewinds="0"><OutputList><ColumnReference Database="[fathom]" Schema="[dbo]" Table="[Period]" Column="Id"/><ColumnReference Database="[fathom]" Schema="[dbo]" Table="[Result]" Column="MetricId"/></OutputList><MemoryFractions Input="1" Output="1"/><Sort Distinct="0"><OrderBy><OrderByColumn Ascending="1"><ColumnReference Database="[fathom]" Schema="[dbo]" Table="[Result]" Column="MetricId"/></OrderByColumn><OrderByColumn Ascending="1"><ColumnReference Database="[fathom]" Schema="[dbo]" Table="[Period]" Column="Id"/></OrderByColumn></OrderBy><RelOp NodeId="14" PhysicalOp="Hash Match" LogicalOp="Inner Join" EstimateRows="107.939" EstimateIO="0" EstimateCPU="0.0863485" AvgRowSize="19" EstimatedTotalSubtreeCost="0.237084" Parallel="0" EstimateRebinds="0" EstimateRewinds="0"><OutputList><ColumnReference Database="[fathom]" Schema="[dbo]" Table="[Period]" Column="Id"/><ColumnReference Database="[fathom]" Schema="[dbo]" Table="[Result]" Column="MetricId"/><ColumnReference Database="[fathom]" Schema="[dbo]" Table="[Result]" Column="PeriodId"/></OutputList><MemoryFractions Input="0" Output="0"/><Hash><DefinedValues/><HashKeysBuild><ColumnReference Database="[fathom]" Schema="[dbo]" Table="[Period]" Column="Id"/></HashKeysBuild><HashKeysProbe><ColumnReference Database="[fathom]" Schema="[dbo]" Table="[Result]" Column="PeriodId"/></HashKeysProbe><RelOp NodeId="15" PhysicalOp="Table Spool" LogicalOp="Eager Spool" EstimateRows="1" EstimateIO="0" EstimateCPU="2.54684e-005" AvgRowSize="11" EstimatedTotalSubtreeCost="0.00431261" Parallel="0" EstimateRebinds="0" EstimateRewinds="0"><OutputList><ColumnReference Database="[fathom]" Schema="[dbo]" Table="[Period]" Column="Id"/></OutputList><Spool PrimaryNodeId="2"/></RelOp><RelOp NodeId="16" PhysicalOp="Clustered Index Scan" LogicalOp="Clustered Index Scan" EstimateRows="14974" EstimateIO="0.129792" EstimateCPU="0.0166284" AvgRowSize="15" EstimatedTotalSubtreeCost="0.14642" TableCardinality="14974" Parallel="0" EstimateRebinds="0" EstimateRewinds="0"><OutputList><ColumnReference Database="[fathom]" Schema="[dbo]" Table="[Result]" Column="MetricId"/><ColumnReference Database="[fathom]" Schema="[dbo]" Table="[Result]" Column="PeriodId"/></OutputList><IndexScan Ordered="1" ForcedIndex="0" ForceScan="0" NoExpandHint="0"><DefinedValues><DefinedValue><ColumnReference Database="[fathom]" Schema="[dbo]" Table="[Result]" Column="MetricId"/></DefinedValue><DefinedValue><ColumnReference Database="[fathom]" Schema="[dbo]" Table="[Result]" Column="PeriodId"/></DefinedValue></DefinedValues><Object Database="[fathom]" Schema="[dbo]" Table="[Result]" Index="[PK_RatioResult]" IndexKind="Clustered"/></IndexScan></RelOp></Hash></RelOp></Sort></RelOp></Update></RelOp><RelOp NodeId="21" PhysicalOp="Clustered Index Delete" LogicalOp="Delete" EstimateRows="5.83333" EstimateIO="0.01" EstimateCPU="5.83333e-006" AvgRowSize="9" EstimatedTotalSubtreeCost="0.0383844" Parallel="0" EstimateRebinds="0" EstimateRewinds="0"><OutputList/><Update DMLRequestSort="0"><Object Database="[fathom]" Schema="[dbo]" Table="[PeriodAlert]" Index="[PK_PeriodAlert]" IndexKind="Clustered"/><RelOp NodeId="22" PhysicalOp="Hash Match" LogicalOp="Inner Join" EstimateRows="5.83333" EstimateIO="0" EstimateCPU="0.0184047" AvgRowSize="15" EstimatedTotalSubtreeCost="0.0283786" Parallel="0" EstimateRebinds="0" EstimateRewinds="0"><OutputList><ColumnReference Database="[fathom]" Schema="[dbo]" Table="[PeriodAlert]" Column="AlertId"/><ColumnReference Database="[fathom]" Schema="[dbo]" Table="[PeriodAlert]" Column="PeriodId"/></OutputList><MemoryFractions Input="0" Output="0"/><Hash><DefinedValues/><HashKeysBuild><ColumnReference Database="[fathom]" Schema="[dbo]" Table="[Period]" Column="Id"/></HashKeysBuild><HashKeysProbe><ColumnReference Database="[fathom]" Schema="[dbo]" Table="[PeriodAlert]" Column="PeriodId"/></HashKeysProbe><RelOp NodeId="23" PhysicalOp="Table Spool" LogicalOp="Eager Spool" EstimateRows="1" EstimateIO="0" EstimateCPU="2.54684e-005" AvgRowSize="11" EstimatedTotalSubtreeCost="0.00431261" Parallel="0" EstimateRebinds="0" EstimateRewinds="0"><OutputList><ColumnReference Database="[fathom]" Schema="[dbo]" Table="[Period]" Column="Id"/></OutputList><Spool PrimaryNodeId="2"/></RelOp><RelOp NodeId="24" PhysicalOp="Clustered Index Scan" LogicalOp="Clustered Index Scan" EstimateRows="140" EstimateIO="0.00534722" EstimateCPU="0.000311" AvgRowSize="15" EstimatedTotalSubtreeCost="0.00565822" TableCardinality="140" Parallel="0" EstimateRebinds="0" EstimateRewinds="0"><OutputList><ColumnReference Database="[fathom]" Schema="[dbo]" Table="[PeriodAlert]" Column="AlertId"/><ColumnReference Database="[fathom]" Schema="[dbo]" Table="[PeriodAlert]" Column="PeriodId"/></OutputList><IndexScan Ordered="1" ForcedIndex="0" ForceScan="0" NoExpandHint="0"><DefinedValues><DefinedValue><ColumnReference Database="[fathom]" Schema="[dbo]" Table="[PeriodAlert]" Column="AlertId"/></DefinedValue><DefinedValue><ColumnReference Database="[fathom]" Schema="[dbo]" Table="[PeriodAlert]" Column="PeriodId"/></DefinedValue></DefinedValues><Object Database="[fathom]" Schema="[dbo]" Table="[PeriodAlert]" Index="[PK_PeriodAlert]" IndexKind="Clustered"/></IndexScan></RelOp></Hash></RelOp></Update></RelOp><RelOp NodeId="26" PhysicalOp="Clustered Index Delete" LogicalOp="Delete" EstimateRows="119.191" EstimateIO="0.01" EstimateCPU="0.000119191" AvgRowSize="9" EstimatedTotalSubtreeCost="0.186497" Parallel="0" EstimateRebinds="0" EstimateRewinds="0"><OutputList/><Update DMLRequestSort="0"><Object Database="[fathom]" Schema="[dbo]" Table="[Amount]" Index="[PK_Amount]" IndexKind="Clustered"/><RelOp NodeId="27" PhysicalOp="Hash Match" LogicalOp="Inner Join" EstimateRows="119.191" EstimateIO="0" EstimateCPU="0.0947385" AvgRowSize="15" EstimatedTotalSubtreeCost="0.176378" Parallel="0" EstimateRebinds="0" EstimateRewinds="0"><OutputList><ColumnReference Database="[fathom]" Schema="[dbo]" Table="[Amount]" Column="AccountId"/><ColumnReference Database="[fathom]" Schema="[dbo]" Table="[Amount]" Column="PeriodId"/></OutputList><MemoryFractions Input="0" Output="0"/><Hash><DefinedValues/><HashKeysBuild><ColumnReference Database="[fathom]" Schema="[dbo]" Table="[Period]" Column="Id"/></HashKeysBuild><HashKeysProbe><ColumnReference Database="[fathom]" Schema="[dbo]" Table="[Amount]" Column="PeriodId"/></HashKeysProbe><RelOp NodeId="28" PhysicalOp="Table Spool" LogicalOp="Eager Spool" EstimateRows="1" EstimateIO="0" EstimateCPU="2.54684e-005" AvgRowSize="11" EstimatedTotalSubtreeCost="0.00431261" Parallel="0" EstimateRebinds="0" EstimateRewinds="0"><OutputList><ColumnReference Database="[fathom]" Schema="[dbo]" Table="[Period]" Column="Id"/></OutputList><Spool PrimaryNodeId="2"/></RelOp><RelOp NodeId="29" PhysicalOp="Clustered Index Scan" LogicalOp="Clustered Index Scan" EstimateRows="16806" EstimateIO="0.0586806" EstimateCPU="0.0186436" AvgRowSize="15" EstimatedTotalSubtreeCost="0.0773242" TableCardinality="16806" Parallel="0" EstimateRebinds="0" EstimateRewinds="0"><OutputList><ColumnReference Database="[fathom]" Schema="[dbo]" Table="[Amount]" Column="AccountId"/><ColumnReference Database="[fathom]" Schema="[dbo]" Table="[Amount]" Column="PeriodId"/></OutputList><IndexScan Ordered="1" ForcedIndex="0" ForceScan="0" NoExpandHint="0"><DefinedValues><DefinedValue><ColumnReference Database="[fathom]" Schema="[dbo]" Table="[Amount]" Column="AccountId"/></DefinedValue><DefinedValue><ColumnReference Database="[fathom]" Schema="[dbo]" Table="[Amount]" Column="PeriodId"/></DefinedValue></DefinedValues><Object Database="[fathom]" Schema="[dbo]" Table="[Amount]" Index="[PK_Amount]" IndexKind="Clustered"/></IndexScan></RelOp></Hash></RelOp></Update></RelOp></Sequence></RelOp></QueryPlan></StmtSimple></Statements></Batch></BatchSequence></ShowPlanXML>
最佳答案
在我看来,主要原因是下一条语句的执行计划:
DELETE FROM Period WHERE CompanyId = 105 AND Type = 7 AND DateRangeId IN (
SELECT Id
FROM DateRange
WHERE Start >= '20110101 00:00:00')
DELETE
的执行计划至少有两个问题
SCAN
运算符(查看 XML 执行计划的图形 View ,我使用了
SQL Sentry Plan Explorer
(link) 的免费版本):
CREATE /*UNIQUE*/ INDEX IN_Result_PeriodId_MetricId
ON dbo.Result (PeriodId, MetricId);
CREATE /*UNIQUE*/ INDEX IN_Amount_PeriodId_AccountId
ON dbo.Amount(PeriodId, AccountId);
--Optional
CREATE /*UNIQUE*/ INDEX IN_PeriodAlert_PeriodId_AlertId
ON dbo.PeriodAlert(PeriodId, AlertId);
关于sql-server - 如何解决主要插入数据的事务之间的死锁?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8095596/
我有 512 行要插入到数据库中。我想知道提交多个插入内容是否比提交一个大插入内容有任何优势。例如 1x 512 行插入 -- INSERT INTO mydb.mytable (id, phonen
已经提出了类似的问题,但由于它总是取决于,我单独询问我的具体情况。 我有一个网站页面,显示来自数据库的一些数据,要从该数据库生成数据,我必须执行一些相当复杂的多连接查询。 数据每天(每晚)更新一次。
我正在使用 MongoDb 和 MySQL 的 python 连接器 pymongo 和 pymysql 测试 MongoDb 和 MySQL,特别是插入功能。 pymongo版本是3.4,pymys
从 C# 应用程序插入大型数组(10M 元素)的最快方法是什么? 到目前为止,我使用的是批量插入。 C# 应用程序生成一个大文本文件,我使用 BULK INSERT 命令加载它。出于好奇,我编写了一个
我编写了一个枚举类型,当我为它运行我创建的 JUnit 测试时会出现以下语法错误: java.lang.Error: Unresolved compilation problems: Synt
我正在尝试创建一个程序,它将单词列表作为输入,并将它们排序为二叉树,以便能够找到它们,例如像字典。这是我到目前为止所做的,但是 newEl -> el = input; 出现段错误,我知道这是因为它试
你好 我有编译这个问题 \begin{equation} J = \sum_{j=1}^{C} \end{equation} 我不断收到错误 missing $ inserted 这很奇怪,因
我需要使用 LINQ to SQL 将记录插入到没有主键的表中。 table 设计得很差;我无法控制表结构。该表由几个 varchar 字段、一个文本字段和一个时间戳组成。它用作其他实体的审计跟踪。
我正在尝试使用 itextsharp 创建 Pdf。我添加了一张包含两列的表格,其中一列包含文本和其他图像。我想要恒定的图像大小 如果另一个单元格中的文本增加并且其他单元格中的图像大小不同,我的图像会
我想把 calory 作为 fruits 的第一个值,我做不到,有人能帮忙吗? $sql = 'INSERT INTO fruits VALUES('', ?, ?, ?)'
我有一个包含季度观察结果的 data.frame。我现在想插入每月值(首选三次,线性很好)。中间目标应该是使用 DATE 创建一个 data.frame作为所有每月观察的索引和缺失值。 谷歌搜索表明我
我想知道是否有办法在值列表中使用“插入”。我正在尝试这样做: insert into tblMyTable (Col1, Col2, Col3) values('value1', value
我想让人们能够在他们的网站中插入单个 Javascript 行,这实际上允许我插入包含我网站内容的固定大小的 IFRAME。它实际上是一个小部件,允许他们搜索我的网站或接收其他信息。这可能吗? 最佳答
我有一个包含时间的表,列名为 time,数据类型为 Date。 在 asp.net 中,我想要一个查询插入日期,另一个查询则在 2 个日期之间进行选择。 我已经尝试过这个: string data =
这是我的代码: create or replace trigger th after insert on stock for each row declare sqty number;
这是一个带有具体示例的通用问题。 我有一个包含三个字段(流派 ID (PK IDENTITY)、流派和子流派)的表。该表对(流派,子流派)组合具有唯一约束。 我想知道如何修改存储过程以在表中不存在时插
因此,我正在遍历二叉树,节点包含字符串,以及读取文件时该字符串是否出现多次。我只查找读取文件时出现次数最多的前 10 个单词,因此本质上我只是比较 int 值。 我的问题是我正在尝试找出一种有效的方法
我有一张机票和行李 map , 每张门票必须是唯一的,并且必须与 map 上的位置相对应 是否可以仅更改行李(m_bagage->秒)而不更改 key ? std::unordered_map m_c
我正在使用 jdbc 驱动程序做一个示例项目。我的问题是,如果我在 2 文本字段中输入空值。 null 不应该加载到数据库中吗?有没有办法避免在数据库中插入空字段?任何帮助将不胜感激。 //Execu
我想知道 SSIS 中是否有特定的插入或更新选项。 如果我想让程序检查它是更新还是插入,我是否必须做一些编码?或者是否可以启用一个选项,以便它会自行检查 PK 是否存在,然后更新,否则插入? 亲切的问
我是一名优秀的程序员,十分优秀!