我有一张统计表,数据量非常大,现在我通过下列语句修改表中的内容,单速度很慢,设置会卡死,请问下我的这条语句可以进行怎样的优化好呢?使用的是hql,也可以转换为sql语句。
语句如下:update TStatistic t
set t.configcount = 0.8, t.statisticCloseState = 0
where t.flowid = 225
and t.statisticprojectid = 2
and t.statisticCloseState = 2
and t.tacheid = 2716
and t.photoCount = 10
语句如下:update TStatistic t
set t.configcount = 0.8, t.statisticCloseState = 0
where t.flowid = 225
and t.statisticprojectid = 2
and t.statisticCloseState = 2
and t.tacheid = 2716
and t.photoCount = 10
解决方案 »
- 求教一个递归查询+聚合的sql语句,求高手哈
- oracle sql developer 怎么过滤掉系统表?
- 我的存储过程运行时间太慢了,是什么原因?
- 请教sql语句
- Oralce 耗资源最多的SQL
- oracle中如何查看不同用户所占的系统资源
- mysql查询 表里面是这样的 id name 1 A,B,C 查询之后怎么像这样显示 id name 1 A 1 B 1 C
- 求教一个问题,请懂的朋友帮帮忙!
- 初学oracle,这条语句在Sql Server 2000能实现,在oraccle中保错.
- 高手请进,安装与设置问题!
- SQL语句报错,说缺失逗号,帮我看看哪来了,我觉得没错呀 请把改过后的 发出来,谢谢,
- 如何判断字段含有某个值然后赋一个其它值
首先要屏蔽掉index,然后再做update动作
一方面,如果你要无差别的更新全部数据,那么index在一定程度上影响了效率.
另一方面,如果你只是更新一条数据,那么还是有索引更快些,因为能更快的定位要删除的数据,不必走全表扫描.
当然上面说的是两种极端情况.
若有的话,请将where 条件后的字段进行排序:主键或唯一索引的排在最左边,那样索引才起作用;
假设statisticprojectid是索引的话,其他字段都没有建立索引,那么应该这样写:
update TStatistic t
set t.configcount = 0.8, t.statisticCloseState = 0
where t.statisticprojectid = 2
and t.flowid = 225
and t.statisticCloseState = 2
and t.tacheid = 2716
and t.photoCount = 10
或者根据rownum,一次更新指定数量的数据 这样会快一点