0 0

这个语句引起的死锁怎么解决?5

我做一个东西,用了线程池实现多线程查询

select url,ids from myurl where ids>900 and ids<=1000
select url,ids from myurl where ids>700 and ids<=800
select url,ids from myurl where ids>0 and ids<=100
select url,ids from myurl where ids>300 and ids<=400
select url,ids from myurl where ids>100 and ids<=200
select url,ids from myurl where ids>200 and ids<=300
select url,ids from myurl where ids>400 and ids<=500
select url,ids from myurl where ids>500 and ids<=600
select url,ids from myurl where ids>600 and ids<=700
select url,ids from myurl where ids>800 and ids<=900
select url,ids from myurl where ids>1100 and ids<=1200
select url,ids from myurl where ids>1000 and ids<=1100
select url,ids from myurl where ids>1200 and ids<=1300
select url,ids from myurl where ids>1400 and ids<=1500
select url,ids from myurl where ids>1300 and ids<=1400
select url,ids from myurl where ids>1600 and ids<=1700
select url,ids from myurl where ids>1500 and ids<=1600
select url,ids from myurl where ids>1800 and ids<=1900
select url,ids from myurl where ids>2000 and ids<=2100
select url,ids from myurl where ids>1700 and ids<=1800
select url,ids from myurl where ids>1900 and ids<=2000
select url,ids from myurl where ids>2200 and ids<=2300
select url,ids from myurl where ids>2100 and ids<=2200
select url,ids from myurl where ids>2400 and ids<=2500
select url,ids from myurl where ids>2600 and ids<=2700
select url,ids from myurl where ids>2800 and ids<=2900
select url,ids from myurl where ids>3000 and ids<=3100
select url,ids from myurl where ids>2300 and ids<=2400
select url,ids from myurl where ids>2500 and ids<=2600
select url,ids from myurl where ids>2700 and ids<=2800
select url,ids from myurl where ids>2900 and ids<=3000
select url,ids from myurl where ids>3100 and ids<=3200
select url,ids from myurl where ids>3300 and ids<=3400
select url,ids from myurl where ids>3500 and ids<=3600
select url,ids from myurl where ids>3200 and ids<=3300
select url,ids from myurl where ids>3400 and ids<=3500
select url,ids from myurl where ids>3700 and ids<=3800
select url,ids from myurl where ids>3600 and ids<=3700
select url,ids from myurl where ids>3900 and ids<=4000
select url,ids from myurl where ids>3800 and ids<=3900
select url,ids from myurl where ids>4000 and ids<=4100
select url,ids from myurl where ids>4100 and ids<=4200
select url,ids from myurl where ids>4300 and ids<=4400
select url,ids from myurl where ids>4200 and ids<=4300
select url,ids from myurl where ids>4400 and ids<=4500
select url,ids from myurl where ids>4600 and ids<=4700
select url,ids from myurl where ids>4800 and ids<=4900
select url,ids from myurl where ids>4500 and ids<=4600
select url,ids from myurl where ids>4700 and ids<=4800
select url,ids from myurl where ids>4900 and ids<=5000
.
.
.


每个线程一条查询语句,现在的问题是线程池15个以下就行,并发15个以上就不行,也没有错误就是不出结果少于15个马上有输出结果。可能
是死锁了,问:怎么查一个表不出现死锁呢?不做修改只查询,sql server的并发用户数改成0了也没用,就这条查询语句怎么改呢?

2010年1月16日 15:25

5个答案 按时间排序 按投票排序

0 0

select * from tablename nolock

2010年1月25日 15:38
0 0

查询的话 都是共享锁 不会死锁. 而且死锁的话会sql server 会报错的 能看得出来。
还是查查其它的问题吧.

2010年1月16日 21:23
0 0

如果采用的是默认的隔离级别,那么应该是不会出现你说的死锁。
是不是没有关闭连接?

2010年1月16日 20:05
0 0

首先你要确定是否数据库死锁,如果是死锁,会抛出进程已牺牲的异常信息。
你可以查询一下当前连接数是多少:
select hostname,count(*) hostconncount from master.dbo.sysprocesses
group by hostname order by count(*) desc

还有你用的sql server数据库,个人版和企业版所限制的并发数是不同的。

2010年1月16日 16:43
0 0

这个要研究下sql server 并发锁机制,

它读表好像也是会锁表吧,

2010年1月16日 16:16

相关推荐

    sqlserver如何快速查询死锁语句

    一旦找到了引起死锁的特定进程,我们可以使用`KILL`命令来终止它,从而释放死锁。例如,如果查询结果显示spid为123的进程是死锁的关键,可以执行如下命令: ```sql KILL 123; ``` 这种方法的优点在于,它可以精确...

    oracle数据库解决死锁

    4. 使用 Oracle 提供的死锁解决工具:Oracle提供了多种工具来解决死锁问题,例如Oracle Enterprise Manager、Oracle SQL Developer等。 在使用PL/SQL语句解决死锁问题时,需要注意以下几点: * 需要了解死锁的原因...

    mysql死锁的一些案例

    这篇博客文章《mysql死锁的一些案例》可能深入探讨了MySQL中死锁的产生原因、表现形式以及解决策略。虽然具体内容未给出,但我们可以根据通常的死锁情况来进行分析。 1. **死锁产生的原因**: - 资源请求顺序不同...

    死锁查询sql语句

    oracle数据库死锁查询并处理,被锁对象、引起死锁原因等查询及解决方法

    Oracle数据库死锁查询语句

    当遇到死锁时,Oracle数据库的死锁检测机制会自动识别并解决,通过选择一个事务进行回滚(通常是最小代价的事务)。你可以通过`ORA-00060`错误代码来识别死锁的发生。为避免死锁,设计良好的事务策略和适当的并发...

    oracle死锁原因解决办法

    事务中的SQL语句执行顺序不当也会引起死锁。如果不同的事务执行了相同的SQL语句序列但顺序不同,可能会导致死锁的发生。例如,事务A先执行了SELECT...FOR UPDATE然后执行UPDATE,而事务B则先执行UPDATE再执行SELECT....

    db2死锁问题分析及解决方案

    通过对DB2死锁问题的深入分析与实践操作,我们可以有效地识别和解决这类问题。这不仅包括了对错误代码的理解、基本的解决步骤,还包括了更为高级的技术手段,如利用监控工具和日志分析来定位问题根源。通过上述方法...

    MySQL中由load data语句引起死锁的解决案例

    这是一个类似数据分析的项目,数据完全通过LOAD DATA语句导入一个InnoDB表中。为方便描述,表结构简化为如下: Create table tb(id int primary key auto_increment, c int not null) engine=innodb; 导入数据的...

    oracle死锁故障分析和诊断解决

    3. **使用死锁检测和自动解决机制**:Oracle提供了死锁检测功能,一旦检测到死锁,系统会自动选择牺牲其中一个事务,解决死锁。 4. **优化SQL语句**:合理使用SQL提示(如`/*+ NO_MERGE */`),减少不必要的全表扫描...

    SQL死锁,删除失败解决办法

    通过这些信息可以快速定位到可能引起死锁的会话。 1. **`v$locked_object`**: Oracle提供的视图,用于显示当前数据库中被锁定的对象信息。 2. **`v$session`**: 显示当前所有会话的信息,包括用户名、会话ID等。 3....

    SqlServer查询和Kill进程死锁的语句

    这个存储过程会列出所有被阻塞的进程及其相关信息,帮助你找出引起死锁的具体SQL语句或存储过程。 另外,还有一个名为 `p_killspid` 的存储过程,用于手动杀死指定数据库中的进程: ```sql USE master; GO IF ...

    Oracle查询死锁表

    - **性能下降**:当系统中存在死锁时,受影响的事务将被挂起,直到死锁被解决,这会导致整体响应时间增加。 - **用户体验受损**:长时间的等待可能会引起用户的不满和抱怨。 - **数据一致性问题**:如果死锁未被正确...

    操作系统中哲学家就餐问题和生产者消费者问题实验报告

    在这个问题中,假设五位哲学家围坐在一张圆桌旁,桌上放着五个叉子,每位哲学家左右各有一个叉子。哲学家们在思考与吃饭之间交替进行,吃饭时需要同时拿起左右两个叉子。若没有适当的同步机制,可能会导致所有哲学家...

    教您如何检查oracle死锁

    3. **优化SQL语句**:对于频繁引起死锁的SQL语句,考虑重新编写或优化其逻辑。 4. **使用Oracle内置功能**:Oracle提供了一些内置工具和参数,如`DBMS_LOCK`包和`DEADLOCK`参数,可以帮助管理员更有效地管理死锁问题...

    oracle解决死锁![参考].pdf

    当死锁发生时,可以使用SQL语句来查找引起死锁的具体操作,例如在SQL Server中,可以使用类似以下的查询: ```sql use master go DECLARE @spid INT, @bl INT DECLARE s_cur CURSOR FOR SELECT 0, blocked FROM ...

    论底层源码的重要性,解决mysql死锁问题

    通过日志文件的分析,特别是Hibernate SQL语句、accesslog和catalina异常日志,可以定位到具体引起死锁的代码段。在本例中,物料和设备使用记录的插入和更新操作可能是死锁的来源。源码分析显示,为了防止重复,先...

    BLOG_Oracle_lhr_Oracle死锁的分类及其模拟.pdf

    这通常会生成一个trace文件,包含死锁的详细信息,供DBA分析。 **死锁模拟** 博客中可能通过示例代码展示了如何模拟不同的死锁场景,如行级死锁和ITL引起的死锁。模拟过程可以帮助理解死锁是如何产生的,并提供了...

    查看数据库死锁SQL

    死锁是指两个或更多的事务在等待对方释放资源时所形成的一种僵局状态,这会导致事务无法继续执行,严重影响数据库系统的性能和稳定性。MySQL作为一种广泛使用的开源关系型数据库管理系统,提供了多种方法来检测和...

Global site tag (gtag.js) - Google Analytics