设为首页 加入收藏

TOP

高水位线引起的查询变慢解决方法(二)
2015-07-24 11:12:30 来源: 作者: 【 】 浏览:2
Tags:水位 引起 查询 解决 方法
------------------- 0 recursive calls 0 db block gets 15730 consistent gets 0 physical reads 0 redo size 520 bytes sent via SQL*Net to client 520 bytes received via SQL*Net from client 2 SQL*Net roundtrips to/from client 0 sorts (memory) 0 sorts (disk) 1 rows processed --一般情况下,表的rowid是不会变的,我们通过ALTER TABLE TABLE_NAME ENABLE ROW MOVEMENT;来打开行迁移 SQL> ALTER TABLE TC_RES_PHY_EQP_PRO_MID_517 ENABLE ROW MOVEMENT; 表已更改。 --整理碎片并回收空间 --此操作相比于ALTER TABLE MOVE: --1.不会消耗更多的表空间 --2.可以在线执行,不会使索引失效 --3.可以使用参数CASCADE,同时收缩表上的索引 --4.ALTER TABLE MOVE之后表空间的位置肯定会发生变化,而SHRINK表空间的位置没有发生变化 SQL> ALTER TABLE TC_RES_PHY_EQP_PRO_MID_517 SHRINK SPACE; 表已更改。 --查询一条记录消耗的成本为:2,一致性读为:4 耗时 0.01 秒 SQL> SELECT 1 FROM TC_RES_PHY_EQP_PRO_MID_517 a WHERE a.obj_id = 17202000000001; 1 ---------- 1 执行计划 ---------------------------------------------------------- Plan hash value: 854298875 ------------------------------------------------------------------------------------------------ | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | ------------------------------------------------------------------------------------------------ | 0 | SELECT STATEMENT | | 1 | 13 | 2 (0)| 00:00:01 | |* 1 | TABLE ACCESS FULL| TC_RES_PHY_EQP_PRO_MID_517 | 1 | 13 | 2 (0)| 00:00:01 | ------------------------------------------------------------------------------------------------ Predicate Information (identified by operation id): --------------------------------------------------- 1 - filter("A"."OBJ_ID"=17202000000001) Note ----- - dynamic sampling used for this statement (level=2) 统计信息 ---------------------------------------------------------- 0 recursive calls 0 db block gets 4 consistent gets 0 physical reads 0 redo size 520 bytes sent via SQL*Net to client 520 bytes received via SQL*Net from client 2 SQL*Net roundtrips to/from client 0 sorts (memory) 0 sorts (disk) 1 rows processed
--此时占用表空间只有4M
SQL> SELECT a.bytes/1024/1024 || 'M' FROM user_segments a WHERE a.segment_name = 'TC_RES_PHY_EQP_PRO_MID_517';

A.BYTES/1024/1024||'M'
-----------------------------------------
4M

当然ENABLE ROW MOVEMENT对系统性能也有影响,在TOM的博客中找到这个关于ROW MOVEMENT的问答:

You Asked

Hi Tom

I have seen your posting on ENABLE ROW MOVEMENT which is available in 10g. It looks a
very nice option since we can relocate and reorganize the heap tables without any outage
since it does not invalidate indexes. But is there any performance hit or any other
disadvantages for using this. I would like to use this in our new application.

Rgds
Anil

and we said...

Well, the tables have to be in an ASSM (Automatic Segment Space Managment) tablespace for
this to work (so if they are not, you have to move them there first in order to do this
over time).

It will necessarily consume processing resources on your machine while running (it will
read the table, it will delete/insert the rows at the bottom of the table to move them
up, it will generate redo, it will generate undo).

I would suggest benchmarking -- collect performance metrics about the table before and
after performing the operation. You would expect full scans to operate more efficiently
after, you would expect index range scans to either be unchanged or "better" as you have
more rows per block packed together (less data spread). You would be looking for that to
happen -- statspack or the tools available in dbconsole would be useful for measuring
that (the amount of work

首页 上一页 1 2 3 下一页 尾页 2/3/3
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇【实战】mariadb审计 下一篇关于数据迁移的方法、步骤和心得

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容:

·数据库:推荐几款 Re (2025-12-25 12:17:11)
·如何最简单、通俗地 (2025-12-25 12:17:09)
·什么是Redis?为什么 (2025-12-25 12:17:06)
·对于一个想入坑Linux (2025-12-25 11:49:07)
·Linux 怎么读? (2025-12-25 11:49:04)