如何快速发现和处理sqlserver数据库的死锁

MSSQL数据库 专栏收录该内容
143 篇文章 2 订阅
推荐:

公告:请您及时更换请请请您正在使用的模版将于2周后被下线,请您及时更换

×
加载中…

用户5575279374的博客

				<div id="bloglink" class="bloglink"><a href="http://blog.sina.com.cn/u/5575279374">http://blog.sina.com.cn/u/5575279374</a>  <a onclick="return false;" class="CP_a_fuc" href="#" id="SubscribeNewRss">[<cite>订阅</cite>]</a><a class="CP_a_fuc" href="javascript:void(scope.pa_add.add('5575279374'));">[<cite>手机订阅</cite>]</a></div>
  </div>
  <div class="blognav" id="blognav">
  			  <div id="blognavBg" class="blognavBg"></div> <div class="blognavInfo"> 
	<span><a href="http://blog.sina.com.cn/u/5575279374">首页</a></span>
  <span><a class="on" href="http://blog.sina.com.cn/s/articlelist_5575279374_0_1.html">博文目录</a></span>
  <!--<span><a href="">图片</a></span>-->
  <span class="last"><a href="http://blog.sina.com.cn/s/profile_5575279374.html">关于我</a></span></div>
  </div>      		      
         <div class="autoskin" id="auto_skin">
   </div>
<!--主题内容开始 -->
<div class="sinablogbody" id="sinablogbody">
	
<!--第一列start-->
<div id="column_1" class="SG_colW21 SG_colFirst"><div id="module_7" class="SG_conn">
博文
特色博文
<!--第二列start-->
<div id="column_2" class="SG_colW73"><div id="module_928" class="SG_conn">
        <div class="SG_connHead">
        <span comp_title="delphi_jiqiao<em>(58)</em>" class="title">delphi_jiqiao<em>(58)</em></span>
                    <span class="edit"> </span>
        </div>
        <div class="SG_connBody">
        	<div class="article_blk">
							<div class="articleList">
		<!-- 列表 START -->
							<div class="articleCell SG_j_linedot1">
					<p class="atc_main SG_dot">
						<span class="atc_ic_f"></span>
						<span class="atc_title">
														<a title="" target="_blank" href="http://blog.sina.com.cn/s/blog_14c50030e0102y9to.html">AV调教手册</a></span> 
													<span class="atc_ic_b"></span>
					</p>
					<p class="atc_info">
												<span class="atc_data" id="count_14c50030e0102y9to">(<span title="评论数">0</span>/<span title="阅读数">22</span>)</span>
												<span class="atc_tm SG_txtc">2017-08-28 18:36</span>
						<span class="atc_set">
						
												
												
																				
																		</span>
					</p>
				</div>
							<div class="articleCell SG_j_linedot1">
					<p class="atc_main SG_dot">
						<span class="atc_ic_f"></span>
						<span class="atc_title">
														<a title="" target="_blank" href="http://blog.sina.com.cn/s/blog_14c50030e0102y88e.html">Delphi如何获取系统服务(即Service…</a></span> 
													<span class="atc_ic_b"></span>
					</p>
					<p class="atc_info">
												<span class="atc_data" id="count_14c50030e0102y88e">(<span title="评论数">0</span>/<span title="阅读数">36</span>)</span>
												<span class="atc_tm SG_txtc">2017-08-26 18:56</span>
						<span class="atc_set">
						
												
												
																				
																		</span>
					</p>
				</div>
							<div class="articleCell SG_j_linedot1">
					<p class="atc_main SG_dot">
						<span class="atc_ic_f"></span>
						<span class="atc_title">
														<a title="" target="_blank" href="http://blog.sina.com.cn/s/blog_14c50030e0102y9fd.html">Delphi&nbsp;fastmm内存机制&nbsp;调试教程</a></span> 
													<span class="atc_ic_b"></span>
					</p>
					<p class="atc_info">
												<span class="atc_data" id="count_14c50030e0102y9fd">(<span title="评论数">0</span>/<span title="阅读数">11</span>)</span>
												<span class="atc_tm SG_txtc">2017-08-18 20:37</span>
						<span class="atc_set">
						
												
												
																				
																		</span>
					</p>
				</div>
							<div class="articleCell SG_j_linedot1">
					<p class="atc_main SG_dot">
						<span class="atc_ic_f"></span>
						<span class="atc_title">
														<a title="" target="_blank" href="http://blog.sina.com.cn/s/blog_14c50030e0102y89l.html">Delphi&nbsp;Treeview&nbsp;操作实例</a></span> 
													<span class="atc_ic_b"></span>
					</p>
					<p class="atc_info">
												<span class="atc_data" id="count_14c50030e0102y89l">(<span title="评论数">0</span>/<span title="阅读数">22</span>)</span>
												<span class="atc_tm SG_txtc">2017-08-16 23:03</span>
						<span class="atc_set">
						
												
												
																				
																		</span>
					</p>
				</div>
							<div class="articleCell SG_j_linedot1">
					<p class="atc_main SG_dot">
						<span class="atc_ic_f"></span>
						<span class="atc_title">
														<a title="" target="_blank" href="http://blog.sina.com.cn/s/blog_14c50030e0102y975.html">[转载]DELPHI制作复杂报表实例,特…</a></span> 
													<span class="atc_ic_b"><img class="SG_icon SG_icon18" src="http://simg.sinajs.cn/blog7style/images/common/sg_trans.gif" width="15" height="15" title="此博文包含图片" align="absmiddle"></span>
					</p>
					<p class="atc_info">
												<span class="atc_data" id="count_14c50030e0102y975">(<span title="评论数">0</span>/<span title="阅读数">9</span>)</span>
												<span class="atc_tm SG_txtc">2017-08-10 23:37</span>
						<span class="atc_set">
						
												
												
																				
																		</span>
					</p>
				</div>
							<div class="articleCell SG_j_linedot1">
					<p class="atc_main SG_dot">
						<span class="atc_ic_f"></span>
						<span class="atc_title">
														<a title="" target="_blank" href="http://blog.sina.com.cn/s/blog_14c50030e0102y96t.html">[转载]Delphi&nbsp;与&nbsp;XML&nbsp;示例(直接利…</a></span> 
													<span class="atc_ic_b"></span>
					</p>
					<p class="atc_info">
												<span class="atc_data" id="count_14c50030e0102y96t">(<span title="评论数">0</span>/<span title="阅读数">11</span>)</span>
												<span class="atc_tm SG_txtc">2017-08-10 23:27</span>
						<span class="atc_set">
						
												
												
																				
																		</span>
					</p>
				</div>
							<div class="articleCell SG_j_linedot1">
					<p class="atc_main SG_dot">
						<span class="atc_ic_f"></span>
						<span class="atc_title">
														<a title="" target="_blank" href="http://blog.sina.com.cn/s/blog_14c50030e0102y96s.html">[转载]delphi读XML</a></span> 
													<span class="atc_ic_b"></span>
					</p>
					<p class="atc_info">
												<span class="atc_data" id="count_14c50030e0102y96s">(<span title="评论数">0</span>/<span title="阅读数">6</span>)</span>
												<span class="atc_tm SG_txtc">2017-08-10 23:26</span>
						<span class="atc_set">
						
												
												
																				
																		</span>
					</p>
				</div>
							<div class="articleCell SG_j_linedot1">
					<p class="atc_main SG_dot">
						<span class="atc_ic_f"></span>
						<span class="atc_title">
														<a title="" target="_blank" href="http://blog.sina.com.cn/s/blog_14c50030e0102y96l.html">[转载]Delphi主从表例子&nbsp;.</a></span> 
													<span class="atc_ic_b"></span>
					</p>
					<p class="atc_info">
												<span class="atc_data" id="count_14c50030e0102y96l">(<span title="评论数">0</span>/<span title="阅读数">4</span>)</span>
												<span class="atc_tm SG_txtc">2017-08-10 23:15</span>
						<span class="atc_set">
						
												
												
																				
																		</span>
					</p>
				</div>
							<div class="articleCell SG_j_linedot1">
					<p class="atc_main SG_dot">
						<span class="atc_ic_f"></span>
						<span class="atc_title">
														<a title="" target="_blank" href="http://blog.sina.com.cn/s/blog_14c50030e0102y95f.html">[转载]Delphi&nbsp;编程规范</a></span> 
													<span class="atc_ic_b"></span>
					</p>
					<p class="atc_info">
												<span class="atc_data" id="count_14c50030e0102y95f">(<span title="评论数">0</span>/<span title="阅读数">12</span>)</span>
												<span class="atc_tm SG_txtc">2017-08-09 21:06</span>
						<span class="atc_set">
						
												
												
																				
																		</span>
					</p>
				</div>
							<div class="articleCell SG_j_linedot1">
					<p class="atc_main SG_dot">
						<span class="atc_ic_f"></span>
						<span class="atc_title">
														<a title="" target="_blank" href="http://blog.sina.com.cn/s/blog_14c50030e0102y88h.html">Delphi使用过程中的几个技巧</a></span> 
													<span class="atc_ic_b"></span>
					</p>
					<p class="atc_info">
												<span class="atc_data" id="count_14c50030e0102y88h">(<span title="评论数">0</span>/<span title="阅读数">12</span>)</span>
												<span class="atc_tm SG_txtc">2017-08-08 22:47</span>
						<span class="atc_set">
						
												
												
																				
																		</span>
					</p>
				</div>
							<div class="articleCell SG_j_linedot1">
					<p class="atc_main SG_dot">
						<span class="atc_ic_f"></span>
						<span class="atc_title">
														<a title="" target="_blank" href="http://blog.sina.com.cn/s/blog_14c50030e0102y8bd.html">DELPHI&nbsp;的&nbsp;{$M&nbsp;+}&nbsp;和{$M&nbsp;-}</a></span> 
													<span class="atc_ic_b"></span>
					</p>
					<p class="atc_info">
												<span class="atc_data" id="count_14c50030e0102y8bd">(<span title="评论数">0</span>/<span title="阅读数">10</span>)</span>
												<span class="atc_tm SG_txtc">2017-08-04 19:13</span>
						<span class="atc_set">
						
												
												
																				
																		</span>
					</p>
				</div>
							<div class="articleCell SG_j_linedot1">
					<p class="atc_main SG_dot">
						<span class="atc_ic_f"></span>
						<span class="atc_title">
														<a title="" target="_blank" href="http://blog.sina.com.cn/s/blog_14c50030e0102y8be.html">用DELPHI&nbsp;开发压缩、解压、自…</a></span> 
													<span class="atc_ic_b"></span>
					</p>
					<p class="atc_info">
												<span class="atc_data" id="count_14c50030e0102y8be">(<span title="评论数">0</span>/<span title="阅读数">23</span>)</span>
												<span class="atc_tm SG_txtc">2017-08-04 19:13</span>
						<span class="atc_set">
						
												
												
																				
																		</span>
					</p>
				</div>
							<div class="articleCell SG_j_linedot1">
					<p class="atc_main SG_dot">
						<span class="atc_ic_f"></span>
						<span class="atc_title">
														<a title="" target="_blank" href="http://blog.sina.com.cn/s/blog_14c50030e0102y7ip.html">dll窗体的创建与调用</a></span> 
													<span class="atc_ic_b"></span>
					</p>
					<p class="atc_info">
												<span class="atc_data" id="count_14c50030e0102y7ip">(<span title="评论数">0</span>/<span title="阅读数">10</span>)</span>
												<span class="atc_tm SG_txtc">2017-08-04 17:26</span>
						<span class="atc_set">
						
												
												
																				
																		</span>
					</p>
				</div>
							<div class="articleCell SG_j_linedot1">
					<p class="atc_main SG_dot">
						<span class="atc_ic_f"></span>
						<span class="atc_title">
														<a title="" target="_blank" href="http://blog.sina.com.cn/s/blog_14c50030e0102y8bf.html">Delphi&nbsp;ADOQuery处理多条SQL语句</a></span> 
													<span class="atc_ic_b"></span>
					</p>
					<p class="atc_info">
												<span class="atc_data" id="count_14c50030e0102y8bf">(<span title="评论数">0</span>/<span title="阅读数">12</span>)</span>
												<span class="atc_tm SG_txtc">2017-08-04 12:39</span>
						<span class="atc_set">
						
												
												
																				
																		</span>
					</p>
				</div>
							<div class="articleCell SG_j_linedot1">
					<p class="atc_main SG_dot">
						<span class="atc_ic_f"></span>
						<span class="atc_title">
														<a title="" target="_blank" href="http://blog.sina.com.cn/s/blog_14c50030e0102y8uu.html">动态产生器</a></span> 
													<span class="atc_ic_b"></span>
					</p>
					<p class="atc_info">
												<span class="atc_data" id="count_14c50030e0102y8uu">(<span title="评论数">0</span>/<span title="阅读数">11</span>)</span>
												<span class="atc_tm SG_txtc">2017-08-02 21:00</span>
						<span class="atc_set">
						
												
												
																				
																		</span>
					</p>
				</div>
							<div class="articleCell SG_j_linedot1">
					<p class="atc_main SG_dot">
						<span class="atc_ic_f"></span>
						<span class="atc_title">
														<a title="" target="_blank" href="http://blog.sina.com.cn/s/blog_14c50030e0102y8uv.html">ASCII码表</a></span> 
													<span class="atc_ic_b"></span>
					</p>
					<p class="atc_info">
												<span class="atc_data" id="count_14c50030e0102y8uv">(<span title="评论数">0</span>/<span title="阅读数">10</span>)</span>
												<span class="atc_tm SG_txtc">2017-08-02 21:00</span>
						<span class="atc_set">
						
												
												
																				
																		</span>
					</p>
				</div>
							<div class="articleCell SG_j_linedot1">
					<p class="atc_main SG_dot">
						<span class="atc_ic_f"></span>
						<span class="atc_title">
														<a title="" target="_blank" href="http://blog.sina.com.cn/s/blog_14c50030e0102y8xi.html">在delphi中TApplicationEvents控件…</a></span> 
													<span class="atc_ic_b"></span>
					</p>
					<p class="atc_info">
												<span class="atc_data" id="count_14c50030e0102y8xi">(<span title="评论数">0</span>/<span title="阅读数">1321</span>)</span>
												<span class="atc_tm SG_txtc">2017-08-02 08:27</span>
						<span class="atc_set">
						
												
												
																				
																		</span>
					</p>
				</div>
							<div class="articleCell SG_j_linedot1">
					<p class="atc_main SG_dot">
						<span class="atc_ic_f"></span>
						<span class="atc_title">
														<a title="" target="_blank" href="http://blog.sina.com.cn/s/blog_14c50030e0102y8uq.html">读写UTF-8、Unicode文件</a></span> 
													<span class="atc_ic_b"></span>
					</p>
					<p class="atc_info">
												<span class="atc_data" id="count_14c50030e0102y8uq">(<span title="评论数">0</span>/<span title="阅读数">10</span>)</span>
												<span class="atc_tm SG_txtc">2017-07-31 18:56</span>
						<span class="atc_set">
						
												
												
																				
																		</span>
					</p>
				</div>
							<div class="articleCell SG_j_linedot1">
					<p class="atc_main SG_dot">
						<span class="atc_ic_f"></span>
						<span class="atc_title">
														<a title="" target="_blank" href="http://blog.sina.com.cn/s/blog_14c50030e0102y8up.html">delphi循环等待并继续处理其它消息</a></span> 
													<span class="atc_ic_b"></span>
					</p>
					<p class="atc_info">
												<span class="atc_data" id="count_14c50030e0102y8up">(<span title="评论数">0</span>/<span title="阅读数">5</span>)</span>
												<span class="atc_tm SG_txtc">2017-07-31 18:54</span>
						<span class="atc_set">
						
												
												
																				
																		</span>
					</p>
				</div>
							<div class="articleCell SG_j_linedot1">
					<p class="atc_main SG_dot">
						<span class="atc_ic_f"></span>
						<span class="atc_title">
														<a title="" target="_blank" href="http://blog.sina.com.cn/s/blog_14c50030e0102y8hl.html">经典的调用窗口函数:调用融合窗口</a></span> 
													<span class="atc_ic_b"></span>
					</p>
					<p class="atc_info">
												<span class="atc_data" id="count_14c50030e0102y8hl">(<span title="评论数">0</span>/<span title="阅读数">11</span>)</span>
												<span class="atc_tm SG_txtc">2017-07-18 10:06</span>
						<span class="atc_set">
						
												
												
																				
																		</span>
					</p>
				</div>
							<div class="articleCell SG_j_linedot1">
					<p class="atc_main SG_dot">
						<span class="atc_ic_f"></span>
						<span class="atc_title">
														<a title="" target="_blank" href="http://blog.sina.com.cn/s/blog_14c50030e0102y89k.html">delphi&nbsp;IOUtils单元&nbsp;处…</a></span> 
													<span class="atc_ic_b"></span>
					</p>
					<p class="atc_info">
												<span class="atc_data" id="count_14c50030e0102y89k">(<span title="评论数">0</span>/<span title="阅读数">24</span>)</span>
												<span class="atc_tm SG_txtc">2017-07-12 20:42</span>
						<span class="atc_set">
						
												
												
																				
																		</span>
					</p>
				</div>
							<div class="articleCell SG_j_linedot1">
					<p class="atc_main SG_dot">
						<span class="atc_ic_f"></span>
						<span class="atc_title">
														<a title="" target="_blank" href="http://blog.sina.com.cn/s/blog_14c50030e0102y88v.html">Delphi&nbsp;Excel导入&nbsp;的通用程序&nbsp;.</a></span> 
													<span class="atc_ic_b"></span>
					</p>
					<p class="atc_info">
												<span class="atc_data" id="count_14c50030e0102y88v">(<span title="评论数">0</span>/<span title="阅读数">10</span>)</span>
												<span class="atc_tm SG_txtc">2017-07-12 18:39</span>
						<span class="atc_set">
						
												
												
																				
																		</span>
					</p>
				</div>
							<div class="articleCell SG_j_linedot1">
					<p class="atc_main SG_dot">
						<span class="atc_ic_f"></span>
						<span class="atc_title">
														<a title="" target="_blank" href="http://blog.sina.com.cn/s/blog_14c50030e0102y87n.html">[转载]TStringList常用操作</a></span> 
													<span class="atc_ic_b"></span>
					</p>
					<p class="atc_info">
												<span class="atc_data" id="count_14c50030e0102y87n">(<span title="评论数">0</span>/<span title="阅读数">17</span>)</span>
												<span class="atc_tm SG_txtc">2017-07-12 12:59</span>
						<span class="atc_set">
						
												
												
																				
																		</span>
					</p>
				</div>
							<div class="articleCell SG_j_linedot1">
					<p class="atc_main SG_dot">
						<span class="atc_ic_f"></span>
						<span class="atc_title">
														<a title="" target="_blank" href="http://blog.sina.com.cn/s/blog_14c50030e0102y87j.html">[转载]delphi中日期格式的设定</a></span> 
													<span class="atc_ic_b"></span>
					</p>
					<p class="atc_info">
												<span class="atc_data" id="count_14c50030e0102y87j">(<span title="评论数">0</span>/<span title="阅读数">14</span>)</span>
												<span class="atc_tm SG_txtc">2017-07-12 12:51</span>
						<span class="atc_set">
						
												
												
																				
																		</span>
					</p>
				</div>
							<div class="articleCell SG_j_linedot1">
					<p class="atc_main SG_dot">
						<span class="atc_ic_f"></span>
						<span class="atc_title">
														<a title="" target="_blank" href="http://blog.sina.com.cn/s/blog_14c50030e0102y87i.html">[转载]在delphi中读取Excel数据</a></span> 
													<span class="atc_ic_b"></span>
					</p>
					<p class="atc_info">
												<span class="atc_data" id="count_14c50030e0102y87i">(<span title="评论数">0</span>/<span title="阅读数">7</span>)</span>
												<span class="atc_tm SG_txtc">2017-07-12 12:51</span>
						<span class="atc_set">
						
												
												
																				
																		</span>
					</p>
				</div>
							<div class="articleCell SG_j_linedot1">
					<p class="atc_main SG_dot">
						<span class="atc_ic_f"></span>
						<span class="atc_title">
														<a title="" target="_blank" href="http://blog.sina.com.cn/s/blog_14c50030e0102y87e.html">[转载]Delphi中array&nbsp;of&amp;nbsp…</a></span> 
													<span class="atc_ic_b"></span>
					</p>
					<p class="atc_info">
												<span class="atc_data" id="count_14c50030e0102y87e">(<span title="评论数">0</span>/<span title="阅读数">15</span>)</span>
												<span class="atc_tm SG_txtc">2017-07-12 12:46</span>
						<span class="atc_set">
						
												
												
																				
																		</span>
					</p>
				</div>
							<div class="articleCell SG_j_linedot1">
					<p class="atc_main SG_dot">
						<span class="atc_ic_f"></span>
						<span class="atc_title">
														<a title="" target="_blank" href="http://blog.sina.com.cn/s/blog_14c50030e0102y87a.html">在Delphi中创建的简单的Excel报表…</a></span> 
													<span class="atc_ic_b"></span>
					</p>
					<p class="atc_info">
												<span class="atc_data" id="count_14c50030e0102y87a">(<span title="评论数">0</span>/<span title="阅读数">20</span>)</span>
												<span class="atc_tm SG_txtc">2017-07-12 12:39</span>
						<span class="atc_set">
						
												
												
																				
																		</span>
					</p>
				</div>
							<div class="articleCell SG_j_linedot1">
					<p class="atc_main SG_dot">
						<span class="atc_ic_f"></span>
						<span class="atc_title">
														<a title="" target="_blank" href="http://blog.sina.com.cn/s/blog_14c50030e0102y85v.html">Delphi中JSon&nbsp;SuperObject&amp;nb…</a></span> 
													<span class="atc_ic_b"></span>
					</p>
					<p class="atc_info">
												<span class="atc_data" id="count_14c50030e0102y85v">(<span title="评论数">0</span>/<span title="阅读数">587</span>)</span>
												<span class="atc_tm SG_txtc">2017-07-11 23:12</span>
						<span class="atc_set">
						
												
												
																				
																		</span>
					</p>
				</div>
							<div class="articleCell SG_j_linedot1">
					<p class="atc_main SG_dot">
						<span class="atc_ic_f"></span>
						<span class="atc_title">
														<a title="" target="_blank" href="http://blog.sina.com.cn/s/blog_14c50030e0102y84z.html">[转载]Delphi&nbsp;的函数覆盖(Override…</a></span> 
													<span class="atc_ic_b"></span>
					</p>
					<p class="atc_info">
												<span class="atc_data" id="count_14c50030e0102y84z">(<span title="评论数">0</span>/<span title="阅读数">95</span>)</span>
												<span class="atc_tm SG_txtc">2017-07-11 16:22</span>
						<span class="atc_set">
						
												
												
																				
																		</span>
					</p>
				</div>
							<div class="articleCell SG_j_linedot1">
					<p class="atc_main SG_dot">
						<span class="atc_ic_f"></span>
						<span class="atc_title">
														<a title="" target="_blank" href="http://blog.sina.com.cn/s/blog_14c50030e0102y84w.html">[转载]Delphi中易混淆的概念&nbsp;Owner…</a></span> 
													<span class="atc_ic_b"></span>
					</p>
					<p class="atc_info">
												<span class="atc_data" id="count_14c50030e0102y84w">(<span title="评论数">0</span>/<span title="阅读数">7</span>)</span>
												<span class="atc_tm SG_txtc">2017-07-11 16:20</span>
						<span class="atc_set">
						
												
												
																				
																		</span>
					</p>
				</div>
							<div class="articleCell SG_j_linedot1">
					<p class="atc_main SG_dot">
						<span class="atc_ic_f"></span>
						<span class="atc_title">
														<a title="" target="_blank" href="http://blog.sina.com.cn/s/blog_14c50030e0102y84u.html">[转载]DELPHI&nbsp;中Format函数功能及…</a></span> 
													<span class="atc_ic_b"></span>
					</p>
					<p class="atc_info">
												<span class="atc_data" id="count_14c50030e0102y84u">(<span title="评论数">0</span>/<span title="阅读数">3</span>)</span>
												<span class="atc_tm SG_txtc">2017-07-11 16:18</span>
						<span class="atc_set">
						
												
												
																				
																		</span>
					</p>
				</div>
							<div class="articleCell SG_j_linedot1">
					<p class="atc_main SG_dot">
						<span class="atc_ic_f"></span>
						<span class="atc_title">
														<a title="" target="_blank" href="http://blog.sina.com.cn/s/blog_14c50030e0102y84l.html">[转载]Delphi&nbsp;Var参数的用法</a></span> 
													<span class="atc_ic_b"></span>
					</p>
					<p class="atc_info">
												<span class="atc_data" id="count_14c50030e0102y84l">(<span title="评论数">0</span>/<span title="阅读数">18</span>)</span>
												<span class="atc_tm SG_txtc">2017-07-11 16:05</span>
						<span class="atc_set">
						
												
												
																				
																		</span>
					</p>
				</div>
							<div class="articleCell SG_j_linedot1">
					<p class="atc_main SG_dot">
						<span class="atc_ic_f"></span>
						<span class="atc_title">
														<a title="" target="_blank" href="http://blog.sina.com.cn/s/blog_14c50030e0102y84k.html">[转载]delphi&nbsp;destructor&nbsp;析构函数</a></span> 
													<span class="atc_ic_b"></span>
					</p>
					<p class="atc_info">
												<span class="atc_data" id="count_14c50030e0102y84k">(<span title="评论数">0</span>/<span title="阅读数">8</span>)</span>
												<span class="atc_tm SG_txtc">2017-07-11 15:59</span>
						<span class="atc_set">
						
												
												
																				
																		</span>
					</p>
				</div>
							<div class="articleCell SG_j_linedot1">
					<p class="atc_main SG_dot">
						<span class="atc_ic_f"></span>
						<span class="atc_title">
														<a title="" target="_blank" href="http://blog.sina.com.cn/s/blog_14c50030e0102y84j.html">[转载]Delphi&nbsp;Self总结</a></span> 
													<span class="atc_ic_b"></span>
					</p>
					<p class="atc_info">
												<span class="atc_data" id="count_14c50030e0102y84j">(<span title="评论数">0</span>/<span title="阅读数">4</span>)</span>
												<span class="atc_tm SG_txtc">2017-07-11 15:57</span>
						<span class="atc_set">
						
												
												
																				
																		</span>
					</p>
				</div>
							<div class="articleCell SG_j_linedot1">
					<p class="atc_main SG_dot">
						<span class="atc_ic_f"></span>
						<span class="atc_title">
														<a title="" target="_blank" href="http://blog.sina.com.cn/s/blog_14c50030e0102y84h.html">[转载]Delphi&nbsp;如何判断字符串是否…</a></span> 
													<span class="atc_ic_b"></span>
					</p>
					<p class="atc_info">
												<span class="atc_data" id="count_14c50030e0102y84h">(<span title="评论数">0</span>/<span title="阅读数">3</span>)</span>
												<span class="atc_tm SG_txtc">2017-07-11 15:53</span>
						<span class="atc_set">
						
												
												
																				
																		</span>
					</p>
				</div>
							<div class="articleCell SG_j_linedot1">
					<p class="atc_main SG_dot">
						<span class="atc_ic_f"></span>
						<span class="atc_title">
														<a title="" target="_blank" href="http://blog.sina.com.cn/s/blog_14c50030e0102y84f.html">[转载]Delphi&nbsp;检查Delphi程序内存…</a></span> 
													<span class="atc_ic_b"></span>
					</p>
					<p class="atc_info">
												<span class="atc_data" id="count_14c50030e0102y84f">(<span title="评论数">0</span>/<span title="阅读数">11</span>)</span>
												<span class="atc_tm SG_txtc">2017-07-11 15:52</span>
						<span class="atc_set">
						
												
												
																				
																		</span>
					</p>
				</div>
							<div class="articleCell SG_j_linedot1">
					<p class="atc_main SG_dot">
						<span class="atc_ic_f"></span>
						<span class="atc_title">
														<a title="" target="_blank" href="http://blog.sina.com.cn/s/blog_14c50030e0102y84c.html">[转载]Delphi&nbsp;MessageBox封装</a></span> 
													<span class="atc_ic_b"></span>
					</p>
					<p class="atc_info">
												<span class="atc_data" id="count_14c50030e0102y84c">(<span title="评论数">0</span>/<span title="阅读数">6</span>)</span>
												<span class="atc_tm SG_txtc">2017-07-11 15:51</span>
						<span class="atc_set">
						
												
												
																				
																		</span>
					</p>
				</div>
							<div class="articleCell SG_j_linedot1">
					<p class="atc_main SG_dot">
						<span class="atc_ic_f"></span>
						<span class="atc_title">
														<a title="" target="_blank" href="http://blog.sina.com.cn/s/blog_14c50030e0102y84a.html">[转载]Delphi高精度计时方法</a></span> 
													<span class="atc_ic_b"></span>
					</p>
					<p class="atc_info">
												<span class="atc_data" id="count_14c50030e0102y84a">(<span title="评论数">0</span>/<span title="阅读数">10</span>)</span>
												<span class="atc_tm SG_txtc">2017-07-11 15:50</span>
						<span class="atc_set">
						
												
												
																				
																		</span>
					</p>
				</div>
							<div class="articleCell SG_j_linedot1">
					<p class="atc_main SG_dot">
						<span class="atc_ic_f"></span>
						<span class="atc_title">
														<a title="" target="_blank" href="http://blog.sina.com.cn/s/blog_14c50030e0102y843.html">[转载]Delphi的内存管理及内存泄露…</a></span> 
													<span class="atc_ic_b"></span>
					</p>
					<p class="atc_info">
												<span class="atc_data" id="count_14c50030e0102y843">(<span title="评论数">0</span>/<span title="阅读数">23</span>)</span>
												<span class="atc_tm SG_txtc">2017-07-11 15:43</span>
						<span class="atc_set">
						
												
												
																				
																		</span>
					</p>
				</div>
							<div class="articleCell SG_j_linedot1">
					<p class="atc_main SG_dot">
						<span class="atc_ic_f"></span>
						<span class="atc_title">
														<a title="" target="_blank" href="http://blog.sina.com.cn/s/blog_14c50030e0102y840.html">[转载]Delphi&nbsp;判断第一个输入的是…</a></span> 
													<span class="atc_ic_b"></span>
					</p>
					<p class="atc_info">
												<span class="atc_data" id="count_14c50030e0102y840">(<span title="评论数">0</span>/<span title="阅读数">7</span>)</span>
												<span class="atc_tm SG_txtc">2017-07-11 15:42</span>
						<span class="atc_set">
						
												
												
																				
																		</span>
					</p>
				</div>
							<div class="articleCell SG_j_linedot1">
					<p class="atc_main SG_dot">
						<span class="atc_ic_f"></span>
						<span class="atc_title">
														<a title="" target="_blank" href="http://blog.sina.com.cn/s/blog_14c50030e0102y83z.html">[转载]Delphi&nbsp;在Object&nbsp;Pascal中,…</a></span> 
													<span class="atc_ic_b"></span>
					</p>
					<p class="atc_info">
												<span class="atc_data" id="count_14c50030e0102y83z">(<span title="评论数">0</span>/<span title="阅读数">4</span>)</span>
												<span class="atc_tm SG_txtc">2017-07-11 15:40</span>
						<span class="atc_set">
						
												
												
																				
																		</span>
					</p>
				</div>
							<div class="articleCell SG_j_linedot1">
					<p class="atc_main SG_dot">
						<span class="atc_ic_f"></span>
						<span class="atc_title">
														<a title="" target="_blank" href="http://blog.sina.com.cn/s/blog_14c50030e0102y83x.html">[转载]DelphiStream对象</a></span> 
													<span class="atc_ic_b"></span>
					</p>
					<p class="atc_info">
												<span class="atc_data" id="count_14c50030e0102y83x">(<span title="评论数">0</span>/<span title="阅读数">5</span>)</span>
												<span class="atc_tm SG_txtc">2017-07-11 15:38</span>
						<span class="atc_set">
						
												
												
																				
																		</span>
					</p>
				</div>
							<div class="articleCell SG_j_linedot1">
					<p class="atc_main SG_dot">
						<span class="atc_ic_f"></span>
						<span class="atc_title">
														<a title="" target="_blank" href="http://blog.sina.com.cn/s/blog_14c50030e0102y83r.html">[转载]delphi中的函数或者过程形参…</a></span> 
													<span class="atc_ic_b"></span>
					</p>
					<p class="atc_info">
												<span class="atc_data" id="count_14c50030e0102y83r">(<span title="评论数">0</span>/<span title="阅读数">20</span>)</span>
												<span class="atc_tm SG_txtc">2017-07-11 15:34</span>
						<span class="atc_set">
						
												
												
																				
																		</span>
					</p>
				</div>
							<div class="articleCell SG_j_linedot1">
					<p class="atc_main SG_dot">
						<span class="atc_ic_f"></span>
						<span class="atc_title">
														<a title="" target="_blank" href="http://blog.sina.com.cn/s/blog_14c50030e0102y83q.html">[转载]Delphi&nbsp;ADOQuery的速度…</a></span> 
													<span class="atc_ic_b"></span>
					</p>
					<p class="atc_info">
												<span class="atc_data" id="count_14c50030e0102y83q">(<span title="评论数">0</span>/<span title="阅读数">129</span>)</span>
												<span class="atc_tm SG_txtc">2017-07-11 15:34</span>
						<span class="atc_set">
						
												
												
																				
																		</span>
					</p>
				</div>
							<div class="articleCell SG_j_linedot1">
					<p class="atc_main SG_dot">
						<span class="atc_ic_f"></span>
						<span class="atc_title">
														<a title="" target="_blank" href="http://blog.sina.com.cn/s/blog_14c50030e0102y83p.html">[转载]Delphi&nbsp;调试&nbsp;通过BreakPoint</a></span> 
													<span class="atc_ic_b"><img class="SG_icon SG_icon18" src="http://simg.sinajs.cn/blog7style/images/common/sg_trans.gif" width="15" height="15" title="此博文包含图片" align="absmiddle"></span>
					</p>
					<p class="atc_info">
												<span class="atc_data" id="count_14c50030e0102y83p">(<span title="评论数">0</span>/<span title="阅读数">0</span>)</span>
												<span class="atc_tm SG_txtc">2017-07-11 15:33</span>
						<span class="atc_set">
						
												
												
																				
																		</span>
					</p>
				</div>
							<div class="articleCell SG_j_linedot1">
					<p class="atc_main SG_dot">
						<span class="atc_ic_f"></span>
						<span class="atc_title">
														<a title="" target="_blank" href="http://blog.sina.com.cn/s/blog_14c50030e0102y7q3.html">自己写的一些Delphi常用函数3</a></span> 
													<span class="atc_ic_b"><img class="SG_icon SG_icon18" src="http://simg.sinajs.cn/blog7style/images/common/sg_trans.gif" width="15" height="15" title="此博文包含图片" align="absmiddle"></span>
					</p>
					<p class="atc_info">
												<span class="atc_data" id="count_14c50030e0102y7q3">(<span title="评论数">0</span>/<span title="阅读数">6</span>)</span>
												<span class="atc_tm SG_txtc">2017-07-04 20:29</span>
						<span class="atc_set">
						
												
												
																				
																		</span>
					</p>
				</div>
							<div class="articleCell SG_j_linedot1">
					<p class="atc_main SG_dot">
						<span class="atc_ic_f"></span>
						<span class="atc_title">
														<a title="" target="_blank" href="http://blog.sina.com.cn/s/blog_14c50030e0102y7pz.html">自己写的一些Delphi常用函数1</a></span> 
													<span class="atc_ic_b"><img class="SG_icon SG_icon18" src="http://simg.sinajs.cn/blog7style/images/common/sg_trans.gif" width="15" height="15" title="此博文包含图片" align="absmiddle"></span>
					</p>
					<p class="atc_info">
												<span class="atc_data" id="count_14c50030e0102y7pz">(<span title="评论数">0</span>/<span title="阅读数">3</span>)</span>
												<span class="atc_tm SG_txtc">2017-07-04 20:19</span>
						<span class="atc_set">
						
												
												
																				
																		</span>
					</p>
				</div>
							<div class="articleCell SG_j_linedot1">
					<p class="atc_main SG_dot">
						<span class="atc_ic_f"></span>
						<span class="atc_title">
														<a title="" target="_blank" href="http://blog.sina.com.cn/s/blog_14c50030e0102y7pv.html">自己写的一些Delphi常用函数</a></span> 
													<span class="atc_ic_b"><img class="SG_icon SG_icon18" src="http://simg.sinajs.cn/blog7style/images/common/sg_trans.gif" width="15" height="15" title="此博文包含图片" align="absmiddle"></span>
					</p>
					<p class="atc_info">
												<span class="atc_data" id="count_14c50030e0102y7pv">(<span title="评论数">0</span>/<span title="阅读数">8</span>)</span>
												<span class="atc_tm SG_txtc">2017-07-04 20:16</span>
						<span class="atc_set">
						
												
												
																				
																		</span>
					</p>
				</div>
							<div class="articleCell SG_j_linedot1">
					<p class="atc_main SG_dot">
						<span class="atc_ic_f"></span>
						<span class="atc_title">
														<a title="" target="_blank" href="http://blog.sina.com.cn/s/blog_14c50030e0102y7p8.html">将中文字符串转换成&nbsp;UTF8&amp;nbs…</a></span> 
													<span class="atc_ic_b"></span>
					</p>
					<p class="atc_info">
												<span class="atc_data" id="count_14c50030e0102y7p8">(<span title="评论数">0</span>/<span title="阅读数">8</span>)</span>
												<span class="atc_tm SG_txtc">2017-07-04 12:33</span>
						<span class="atc_set">
						
												
												
																				
																		</span>
					</p>
				</div>
							<div class="articleCell SG_j_linedot1">
					<p class="atc_main SG_dot">
						<span class="atc_ic_f"></span>
						<span class="atc_title">
														<a title="" target="_blank" href="http://blog.sina.com.cn/s/blog_14c50030e0102y7k3.html">Delphi指针运用理解</a></span> 
													<span class="atc_ic_b"></span>
					</p>
					<p class="atc_info">
												<span class="atc_data" id="count_14c50030e0102y7k3">(<span title="评论数">1</span>/<span title="阅读数">7</span>)</span>
												<span class="atc_tm SG_txtc">2017-06-30 20:22</span>
						<span class="atc_set">
						
												
												
																				
																		</span>
					</p>
				</div>
					<!-- 列表END -->
		</div>
					<div class="SG_page">
					<ul class="SG_pages">
						<li class="SG_pgon" title="当前所在页">1</li><li><a href="http://blog.sina.com.cn/s/articlelist_5575279374_6_2.html" title="跳转至最后一页">2</a></li><li class="SG_pgnext"><a href="http://blog.sina.com.cn/s/articlelist_5575279374_6_2.html" title="跳转至第 2 页">下一页&nbsp;&gt;</a></li>&nbsp;&nbsp;<span style="color:#888888;">共2页</span>						</ul>
				</div>
			</div>
			<div class="SG_connFoot"></div>
        </div>       
        
      </div></div>
<!--第二列start-->

<!--第三列start-->
<div id="column_3" class="SG_colWnone"><div style="width:0px;height:0.1px;margin:0px;">&nbsp;&nbsp;</div></div>
<!--第三列end-->

<div id="articlebody" class="artical" favmd5="{&quot;14d5a51a90102yqvr&quot;:&quot;7191486dfb39933b66127ad5395fbc05&quot;}">
	<div class="articalTitle"> 
		
							<h2 id="t_14d5a51a90102yqvr" class="titName SG_txta">如何快速发现和处理sqlserver数据库的死锁</h2>
		
				<span class="img2">
			<img width="15" height="15" align="absmiddle" title="此博文包含图片" src="http://simg.sinajs.cn/blog7style/images/common/sg_trans.gif" class="SG_icon SG_icon18">	
		</span>
				<span class="time SG_txtc">(2018-11-24 12:52:33)</span><div class="turnBoxzz"><a href="javascript:;" class="SG_aBtn SG_aBtn_ico SG_turn" action-type="reblog" action-data="{srcBlog:1, blogId:'14d5a51a90102yqvr'}"><cite><img class="SG_icon SG_icon111" src="http://simg.sinajs.cn/blog7style/images/common/sg_trans.gif" width="15" height="15" align="absmiddle">转载<em class="arrow">▼</em></cite></a></div>		</div>
	<div class="articalTag" id="sina_keyword_ad_area">
		<table>
			<tbody><tr>
				<td class="blog_tag">
				<script>
				var $tag='';
				var $tag_code='0073979c943b4cc520b8f1ebb672022f';
				var $r_quote_bligid='14d5a51a90102yqvr';
				var $worldcup='0';
				var $worldcupball='0';
				</script>
									</td>
				<td class="blog_class">
										<span class="SG_txtb">分类:</span>
					<a target="_blank" href="http://blog.sina.com.cn/s/articlelist_5592732073_1_1.html">oracle</a>
									</td>
			</tr>
		</tbody></table>
	</div>
					<!-- 正文开始 -->
	<div id="sina_keyword_ad_area2" class="articalContent   newfont_family">
		<div>首先在sqlserver的查询分析器中查看特定数据库被阻塞的进程</div>

select * from sysprocesses where dbid in (select dbid from sysdatabases where name='www_rztong_com_cn') and blocked>0 

然后查看阻塞超时设置

SELECT @@LOCK_TIMEOUT

再次根据阻塞的进程ID查看阻塞语句

dbcc inputbuffer(108)

上面的108就是阻塞进程的ID。根据发现的语句可以用来分析是程序代码的哪部分造成了这个死锁,从而得以解决。

如果事情紧急,可以立即杀死阻塞进程,从而终结死锁的情况

kill 108



在实际操作中可能会出现kill 108执行不了的情况,这个时候处理就比较麻烦,需要是数据库处于独占情况下才能处理
--------------------- 
作者:sxf359 
来源:CSDN 
原文:https://blog.csdn.net/sxf359/article/details/54669866 
版权声明:本文为博主原创文章,转载请附上博文链接!

前些天写一个存储过程,存储过程中使用了事务,后来我把一些代码注释掉来进行调试找错,突然发现一张表被锁住了,原来是创建事务的代码忘记注释掉。本文表锁住了的解决方法。 其实不光是上面描述的情况会锁住表,还有很多种场景会使表放生死锁,解锁其实很简单,下面用一个示例来讲解: 1 首先创建一个测试用的表:

CREATE TABLE Test
(
    TID INT IDENTITY(1,1)
)

2 执行下面的SQL语句将此表锁住:

SELECT * FROM Test WITH (TABLOCKX)

3 通过下面的语句可以查看当前库中有哪些表是发生死锁的:

SELECT request_session_id spid,OBJECT_NAME(resource_associated_entity_id)tableName
FROM  sys.dm_tran_locks
WHERE resource_type='OBJECT ' 

4 上面语句执行结果如下:

  • spid :被锁进程ID。
  • tableName:发生死锁的表名。

5 只需要使用kill关键字来杀掉被锁的进程ID就可以对表进行解锁:

KILL 52

 
  

SQL Server死锁的分析、处理与预防

1、基本原理

      所谓“死锁”,在操作系统的定义是:在一组进程中的各个进程均占有不会释放的资源,但因互相申请被其他进程所站用不会释放的资源而处于的一种永久等待状态。

      定义比较抽象,下图可以帮助你比较直观的理解死锁:

 

      出现死锁需要满足几个必要条件:

      a)互斥:进程独占资源,资源不共享;

      b)请求与保持:已经得到资源的进程可以再次申请新资源;

      c)不剥夺:已分配的资源不能被其它进程强制剥夺;

      d)环路等待:几个进程组成环路,都在相互等待正被占用的资源;

      对应到SQL Server中,在2个或多个任务中(insert、update、delete、select、alter table或Tran事务等等),如果每个任务锁定了其它任务想要锁定的资源,会造成这些任务永久阻塞,从而出现死锁。这些资源可能是:单行数据(RID、HEAP堆中的行)、索引中的键(KEY,行锁)、页(Page,8KB)、区(Extent,8个连续页)、堆或B树、表(Table,数据和索引)、文件(File,数据库文件)、整个数据库(DataBase)。

      如果系统中的资源不足或者资源分配策略不当,会导致因进程间的资源争用产生死锁现象。但更多的可能是程序员的程序有问题。“锁”有多种方式,如意向锁、共享锁、排他锁等等。锁还有多种粒度,如行锁、表锁。

      了解了死锁产生的原因,就可以最大可能的避免与预防死锁。只要上述4个必要条件中有1个不满足,就不会发生死锁。所以,在系统设计、实现阶段就可以在资源分配与占用、资源访问顺序等方面采取必要措施。

2、一个例子

      直面死锁,来看一个例子:如图1所示,新建一个查询窗口,并利用事务的原子特性和update语句的排他锁特性把2个表中的记录锁住;如图2所示,再次新建一个查询窗口,2条很简单的SQL语句长时间仍没有执行完成。

3、检测与排查

3.1 通过Profile工具看死锁

      Profile是SQL Server自带的跟踪分析工具,开启Profile来捕捉死锁信息可以更直观的看到相关信息。

3.2 通过系统存储过程看死锁

      sp_who和sp_lock是SQL Server的2个系统存储过程,可以用它们来查询数据库中的锁情况。sp_who提供有关的数据库实例中当前用户、会话和进程的信息,如下图,我们看到spid=56的会话(UPDATE语句)被spid=54的会话阻塞。

      sp_lock提供有关锁的信息,如下图。我们可以通过spid知道是哪个会话锁住了资源,可以通过ObjId知道被锁住的资源是什么。

      执行如下SQL脚本获取被锁资源和资源所属的数据库:

SELECT OBJECT_NAME(421666738) AS LockedResource,DB_NAME(11) AS DBName;
--------------------------------------------------------------
LockedResource                  DBName
--------------------------------------------------------------
tb_TE_SizeInformation           JYBGDB

      执行如下脚本获取锁资源的会话正在执行的SQL脚本:

复制代码
DBCC INPUTBUFFER(54);
---------------------------------------------------------------------------
EventInfo                                  EventType                Parameters
---------------------------------------------------------------------------
--根据事务的原子性实现个必要条件中                Language Event           0             
--请求和等待 BEGIN TRAN
--update语句在数据行上加排他锁
--和其它所有锁不兼容
--实现个必要条件中的:互斥
UPDATE tb_TE_BrandInformation SET IsCompensate=0
UPDATE tb_TE_SizeInformation SET [Description]=''
复制代码

4、处理方式

4.1 SQL Server自动处理

      “无为而治”。当数据库产生死锁时,SQL Server通过一个叫“锁监视器”的东西捕获死锁信息,并根据一定的规则自动选择一个SQL作为锁的牺牲品,并返回如下报错信息:

服务器: 消息 1205,级别 13,状态 50,行 1

事务(进程 ID  xx)与另一个进程已被死锁在  lock 资源上,且该事务已被选作死锁牺牲品。请重新运行该事务。

      如果你对数据库还不够了解,那建议你向其他有经验的人求助,在此之前不要轻易对数据库进行修改。

4.2 Kill会话

      通过3.2中提到的系统存储过程可以获取到与死锁相关的信息。可以查询其中是哪个spid导致的死锁,并使用Kill spid的方法把它干掉。但是这只能是一种临时的解决方案,我们不可能一遇到死锁就在用户的生产环境里排查死锁、Kill sp。同样的道理,也不可能一遇到死锁就重启SQL Server服务,甚至重启数据库服务器。

      SQL脚本:

Kill  54;        --此处54即分析后得到的spid值

4.3 设定锁请求超时

      默认情况下,数据库没有锁定超时期限。也就是说一个会话在申请新的资源时,如果这个资源已经被其它进程锁定,那么本会话会一直处于等待状态。这样无疑是有问题的。我们可以通过SQL命令来设定锁请求超时。也可以访问全局变量 @@LOCK_TIMEOUT 来查看这个值。

SET LOCK_TIMEOUT  20000;     --单位是毫秒

      当请求锁超过设定时间时,SQL Server将返回错误。我们的程序可以根据返回的错误来进行响应的处理,避免长时间的用户等待。

服务器: 消息 1222,级别 16,状态 50,行 1

已超过了锁请求超时时段。

      当然,使用这种方式来处理所有的锁请求是不合适的,也是不负责任的。在多数情况下是我们的程序的设计、实现的问题导致了死锁。在处理过程中,我们既要治标,更要治本。

4.4 修改程序

      在3.2的最后,我们通过系统存储过程和几个命令找到了锁定资源的SQL命令。以这次LL项目为例,我们发现是WEB管理系统上的一个统计报表(SELECT)在执行过程中长时间的那一个生产信息表锁定,导致现场各机台上位机系统想要插入新的生产记录(INSERT)时长时间等待。所以在现场项目组每次重新启动SQL Server服务或者重启数据库服务器2个小时以后,这个问题依然重复出现。

      这个时候如果采用Kill掉这个统计报表请求的方式处理,结果和重启SQL Server服务、重启数据库服务器没有区别,2个小时后问题依旧。如果采用设定锁请求超时的方式处理,那么这个统计报表每次执行都不会获得想要的结果,而且每次执行也会锁定一定的时间导致现场上位机的等待。

      这次我们的处理措施是:1)暂时禁用了WEB管理系统上的这个报表功能;2)重启了SQL Server服务;3)优化报表的SQL语句;4)启用报表功能。之后的一段时间没有再次出现这样的问题。

      通过对这个报表的性能优化,这个问题算是解决的差不多了。但是经过事后了解,发现报表的性能问题并不在于开发人员的疏忽或水平不够。问题的根本在这个生产信息表的设计有问题。在一个数据量达到1000w级的表中,我们采用char(10)来保存日期值,虽然INSERT、UPDATE、DELETE时没有问题,但是在执行SELECT且这个日期值字段作为过滤条件时发生性能问题是必然的。经过测试,这个字段的数据类型改为datetime时的执行时间不到性能优化后的10%。

      所以,不但是在开发阶段,早在设计阶段就已经有了性能隐患。

4.5 升级硬件

      不赘述。

5、如何预防

      首先要理解,在多并发的环境中死锁是不可避免的,只能通过合理的数据库设计、良好的索引、适当的查询语句以及隔离等级等措施尽量减少死锁。

      最开始列出了死锁的4个必要条件,只要想办法破坏任意1个或多个条件就可以避免产生死锁。下列方法有助于最大限度的降低死锁:

      a) 按同一顺序访问对象;

      b)避免事务中的用户交互,也就是在事务执行过程中不要包含用户交互的步骤;

      c)保持事务简短并在一个批处理中;

      d)SELECT语句加WITH(NOLOCK)提示;

SELECT * FROM TABLE1 WITH(NOLOCK);

SELECT * FROM TABLE2 WITH(NOLOCK);

 

      这种写法在执行中不对查询到的资源加锁,就允许2条SQL可以并发地访问同一资源。但是加WITH(NOLOCK)提示可能会导致脏读!!!

      e)使用较低的隔离级别;

      暂不需要了解,不赘述。

      f)使用绑定连接;

      处理程序端的死锁,非数据库端,不赘述。

6、结束语

       项目实施过程中遇到死锁现象在所难免。通过前面的介绍,希望大家能够对它有一个比较简单的认识,在遇到异常情况的时候不至于束手无策。如果以上内容有什么技术上不对的问题或观点,欢迎大家直接向我提出来一起研究沟通,也欢迎大家在遇到其它数据库方面的问题时能和我一起探讨,共同提高。

  • 0
    点赞
  • 0
    评论
  • 0
    收藏
  • 打赏
    打赏
  • 扫一扫,分享海报

参与评论 您还未登录,请先 登录 后发表或查看评论
©️2022 CSDN 皮肤主题:大白 设计师:CSDN官方博客 返回首页

打赏作者

qq_18932003

你的鼓励将是我创作的最大动力

¥2 ¥4 ¥6 ¥10 ¥20
输入1-500的整数
余额支付 (余额:-- )
扫码支付
扫码支付:¥2
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、C币套餐、付费专栏及课程。

余额充值