表和索引真实使用量分析
1、表的使用分析
参考文章:How to Determine Real Space used by a Table (Below the High Water Mark) (Doc ID 77635.1)
**Checked for relevance on 31-Oct-2011*** PURPOSE This article describes how to find out how many blocks are really being used within a table ie. are not empty. Please note that this article does not cover what to do when chaining is taking place.SCOPE & APPLICATION For DBA's needing to determine how many blocks within a table are empty blocks.How many blocks contain data (are not empty) -------------------------------------------- Each row in the table has pseudocolumn called ROWID.This pseudo contains information about physical location of the row in format ————block_number.row.file If the table is stored in a tablespace which has one datafile, all we have to do is to get DISTINCT number of block_number from ROWID column of this table.But if the table is stored in a tablespace with more than onedatafile then you can have the same block_number but in different datafiles so we have to get DISTINCT number of block_number+file from ROWID.
(如果表示存在一个只有一个数据文件的的表空间内,我们只要从ROWID中找出distinct的数量,就得到了数据块使用的个数;
但是,对于一个表存储在多个数据文件里的,就会有相同的block numner,但是数据文件号是不同的,所以这个时候可以distinct ROWID block_number+file)
SQL> create table tab_test4 as select * from dba_objects;
Table created.
SQL> select count(*) from tab_test4;
COUNT(*)
----------
74491
SQL> ANALYZE TABLE TAB_TEST4 ESTIMATE STATISTICS; (这样统计信息就可以存入usr_tables表中了)
Table analyzed.
通过如下命令,查看使用block的数量:
SELECT COUNT (DISTINCT
DBMS_ROWID.ROWID_BLOCK_NUMBER(rowid)||
DBMS_ROWID.ROWID_RELATIVE_FNO(rowid)) "Used"
FROM user_test1.tab_test4;
Used
------------
1010
也就是说,有1010个数据块被使用。
执行truncate表:
SQL> TRUNCATE TABLE tab_test4;
Table truncated.
SQL> ANALYZE TABLE TAB_TEST4 ESTIMATE STATISTICS;
Table analyzed.
再次查看:
SELECT table_name, num_rows,blocks,empty_blocks
FROM dba_tables
WHERE table_name='TAB_TEST4';
2、索引使用分析
参考文章:How to Find Out How Much Space an Index is Using (Doc ID 33343.1)
表和索引真实使用量分析相关推荐
- Oracle表与索引的分析及索引重建
1.分析表与索引(analyze 不会重建索引) analyze table tablename compute statistics 等同于 analyze table tablename comp ...
- 有序表的索引顺序结构查找次数分析
有序表的索引顺序结构查找次数分析 @(算法学习) 为了提高查找效率,对65025个元素的有序顺序表建立索引顺序结构,在最好情况下查找到表中已有元素,平均需要执行(B)次关键字比较. A. 10 B. ...
- 索引顺序表(分块)查找分析
索引顺序表(分块)查找 一.分块查找表存储结构 1."分块有序"的线性表 2.索引表 二.分块查找的基本思想 三.分块查找示例 四.算法分析--平均查找长度ASL 索引顺序查找又称 ...
- 基础第三-MySQL-多表查询-索引-事务笔记
多表查询介绍 目标 了解什么是多表查询,及多表查询的两种方式 什么是多表查询 查询多张表才能得到我们想要的数据 比如:我们想查询到孙悟空在哪个部门,需要将部门表和员工表同时进行查询 [外链图片转存失败 ...
- 【MySQL】InnoDB行格式、数据页结构以及索引底层原理分析
目录 一.MySQL架构图 二.InnoDB数据页结构 2.1 局部性原理 2.2 InnoDB的数据页格式 三.InnoDB的行格式 3.1 Compact行格式 3.1.1 变长字段长度列表 3. ...
- mysql多表连接 索引_MySQL多表查询之外键、表连接、子查询、索引
一.外键: 1.什么是外键 2.外键语法 3.外键的条件 4.添加外键 5.删除外键 1.什么是外键: 主键:是唯一标识一条记录,不能有重复的,不允许为空,用来保证数据完整性 外键:是另一表的主键, ...
- mysql的索引优化_MySQL索引优化与分析(重要)
建表SQL CREATE TABLE staffs ( id INT PRIMARY KEY AUTO_INCREMENT, NAME VARCHAR (24) NULL DEFAULT '' COM ...
- SQL Server 表和索引存储结构
SQL Server 表和索引存储结构 杜飞 在上一篇文章中,我们介绍了SQL Server数据文件的页面类型,系统通过96个字节的头部信息和系统表从逻辑层面上将表的存储结构管理起来,具体到表的存储结 ...
- oracle如何复制表的索引,Oracle表与索引管理
1.分析表与索引 analyze table tablename compute statistics 等同于 analyze table tablename compute statistics f ...
最新文章
- java pinyin4j 首字母_通讯录之按汉字首字母排序 --java--pinyin4J
- HTML粘性滑块导航源码-可用来做首页
- Linux系统管理第六周作业【Linux微职位】
- K02-01通过简单exe介绍pro基本配置
- 梦想cad控件 android,梦想CAD控件 2018.7.26更新
- android gdb gdbserver
- python 对象和json互相转换
- 2021-09-06146. LRU 缓存机制 哈希表
- SQL:数据库更新语句操作实例
- Clover-系统集成功能可能被安全软件阻止,请关闭安全软件后重启Clover的解决方案
- matlab 直方图规定化,直方图规定化
- 在这个薄情的世界里深情的活这
- Excel的使用-查看公式引用的单元格【跬步】
- 关于java中输出流flush()方法
- [BZOJ4379][POI2015]Modernizacja autostrady[树的直径+换根dp]
- javaweb实验室预约管理系统
- VPP使用详解——基于VPP的VLAN配置
- 【原创】IOS游戏辅助--天天酷跑助手的实现
- DTX-1800还需要校准吗?
- datatable render formatter