热门标签 | HotTags
当前位置:  开发笔记 > 数据库 > 正文

Oracle11g统计表空间使用率很慢-mysql教程

现场统计表空间很慢。SELECTT1.TABLESPACE_NAME,TOTAL_SPACE,TOTAL_SPACE

现场统计表空间很慢。 SELECT T1.TABLESPACE_NAME, TOTAL_SPACE, TOTAL_SPACE - FREE_SPACE USED_SPACE, FREE_SPACE FROM (SELECT TABLESPACE_NAME, SUM(BYTES) / 1024 / 1024/ 1024 TOTAL_SPACE FROM DBA_DATA_FILES GROUP BY TABLESPACE_NAME) T1, (SELECT

现场统计表空间很慢。
SELECT T1.TABLESPACE_NAME,
TOTAL_SPACE,
TOTAL_SPACE - FREE_SPACE USED_SPACE,
FREE_SPACE
FROM (SELECT TABLESPACE_NAME, SUM(BYTES) / 1024 / 1024/ 1024 TOTAL_SPACE
FROM DBA_DATA_FILES
GROUP BY TABLESPACE_NAME) T1,
(SELECT TABLESPACE_NAME, SUM(BYTES) / 1024 / 1024/ 1024 FREE_SPACE
FROM DBA_FREE_SPACE
GROUP BY TABLESPACE_NAME) T2

WHERE T1.TABLESPACE_NAME = T2.TABLESPACE_NAME;


主要是这条SQL慢,花了五分半钟,看是和垃圾回收站相关的表。

SELECT TABLESPACE_NAME, SUM(BYTES) / 1024 / 1024/ 1024 FREE_SPACE
FROM DBA_FREE_SPACE GROUP BY TABLESPACE_NAME
--------------------------------------------------------------------------------------------------------------------------------------------------
| Id | Operation | Name | Starts | E-Rows | A-Rows | A-Time | Buffers | Reads | OMem | 1Mem | Used-Mem |
--------------------------------------------------------------------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1 | | 12 |00:05:29.43 | 561K| 102K| | | |
| 1 | HASH GROUP BY | | 1 | 7 | 12 |00:05:29.43 | 561K| 102K| 3532K| 1450K| 1099K (0)|
| 2 | VIEW | DBA_FREE_SPACE | 1 | 13208 | 35897 |00:05:29.42 | 561K| 102K| | | |
| 3 | UNION-ALL | | 1 | | 35897 |00:05:29.41 | 561K| 102K| | | |
| 4 | NESTED LOOPS | | 1 | 1 | 0 |00:00:00.01 | 19 | 0 | | | |
| 5 | NESTED LOOPS | | 1 | 1 | 0 |00:00:00.01 | 19 | 0 | | | |
| 6 | TABLE ACCESS CLUSTER | FET$ | 1 | 1 | 0 |00:00:00.01 | 19 | 0 | | | |
| 7 | INDEX FULL SCAN | I_TS# | 1 | 1 | 18 |00:00:00.01 | 1 | 0 | | | |
|* 8 | TABLE ACCESS CLUSTER | TS$ | 0 | 1 | 0 |00:00:00.01 | 0 | 0 | | | |
|* 9 | INDEX UNIQUE SCAN | I_TS# | 0 | 1 | 0 |00:00:00.01 | 0 | 0 | | | |
|* 10 | INDEX UNIQUE SCAN | I_FILE2 | 0 | 1 | 0 |00:00:00.01 | 0 | 0 | | | |
| 11 | NESTED LOOPS | | 1 | 13126 | 13608 |00:00:00.18 | 1864 | 0 | | | |
| 12 | NESTED LOOPS | | 1 | 13126 | 13608 |00:00:00.16 | 1860 | 0 | | | |
|* 13 | TABLE ACCESS CLUSTER | TS$ | 1 | 12 | 12 |00:00:00.01 | 19 | 0 | | | |
| 14 | INDEX FULL SCAN | I_TS# | 1 | 1 | 18 |00:00:00.01 | 1 | 0 | | | |
|* 15 | FIXED TABLE FIXED INDEX | X$KTFBFE (ind:1) | 12 | 1059 | 13608 |00:00:00.15 | 1841 | 0 | | | |
|* 16 | INDEX UNIQUE SCAN | I_FILE2 | 13608 | 1 | 13608 |00:00:00.01 | 4 | 0 | | | |
|* 17 | HASH JOIN | | 1 | 80 | 22289 |00:05:29.22 | 559K| 102K| 2461K| 2461K| 2209K (0)|
| 18 | NESTED LOOPS | | 1 | 84 | 22289 |00:05:29.20 | 559K| 102K| | | |
|* 19 | HASH JOIN | | 1 | 5807 | 22289 |00:05:29.14 | 559K| 102K| 1557K| 1557K| 1673K (0)|
| 20 | TABLE ACCESS FULL | RECYCLEBIN$ | 1 | 5807 | 5807 |00:00:00.01 | 529 | 0 | | | |
| 21 | FIXED TABLE FULL | X$KTFBUE | 1 | 100K| 990K|00:05:28.61 | 558K| 102K| | | |
|* 22 | INDEX UNIQUE SCAN | I_FILE2 | 22289 | 1 | 22289 |00:00:00.04 | 4 | 0 | | | |
|* 23 | TABLE ACCESS CLUSTER | TS$ | 1 | 12 | 12 |00:00:00.01 | 19 | 0 | | | |
| 24 | INDEX FULL SCAN | I_TS# | 1 | 1 | 18 |00:00:00.01 | 1 | 0 | | | |
| 25 | NESTED LOOPS | | 1 | 1 | 0 |00:00:00.01 | 19 | 0 | | | |
| 26 | NESTED LOOPS | | 1 | 968 | 0 |00:00:00.01 | 19 | 0 | | | |
| 27 | NESTED LOOPS | | 1 | 1 | 0 |00:00:00.01 | 19 | 0 | | | |
| 28 | NESTED LOOPS | | 1 | 1 | 0 |00:00:00.01 | 19 | 0 | | | |
|* 29 | TABLE ACCESS CLUSTER | TS$ | 1 | 1 | 0 |00:00:00.01 | 19 | 0 | | | |
| 30 | INDEX FULL SCAN | I_TS# | 1 | 1 | 18 |00:00:00.01 | 1 | 0 | | | |
| 31 | TABLE ACCESS CLUSTER | UET$ | 0 | 1 | 0 |00:00:00.01 | 0 | 0 | | | |
|* 32 | INDEX RANGE SCAN | I_FILE#_BLOCK# | 0 | 1 | 0 |00:00:00.01 | 0 | 0 | | | |
|* 33 | INDEX UNIQUE SCAN | I_FILE2 | 0 | 1 | 0 |00:00:00.01 | 0 | 0 | | | |
|* 34 | INDEX RANGE SCAN | RECYCLEBIN$_TS | 0 | 968 | 0 |00:00:00.01 | 0 | 0 | | | |
|* 35 | TABLE ACCESS BY INDEX ROWID| RECYCLEBIN$ | 0 | 2 | 0 |00:00:00.01 | 0 | 0 | | | |
--------------------------------------------------------------------------------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
8 - filter("TS"."BITMAPPED"=0)
9 - access("TS"."TS#"="F"."TS#")
10 - access("F"."TS#"="FI"."TS#" AND "F"."FILE#"="FI"."RELFILE#")
13 - filter((INTERNAL_FUNCTION("TS"."ONLINE$") AND "TS"."CONTENTS$"=0 AND "TS"."BITMAPPED"<>0))
15 - filter("TS"."TS#"="F"."KTFBFETSN")
16 - access("F"."KTFBFETSN"="FI"."TS#" AND "F"."KTFBFEFNO"="FI"."RELFILE#")
17 - access("TS"."TS#"="RB"."TS#")
19 - access("U"."KTFBUESEGTSN"="RB"."TS#" AND "U"."KTFBUESEGFNO"="RB"."FILE#" AND "U"."KTFBUESEGBNO"="RB"."BLOCK#")
22 - access("RB"."TS#"="FI"."TS#" AND "U"."KTFBUEFNO"="FI"."RELFILE#")
23 - filter((INTERNAL_FUNCTION("TS"."ONLINE$") AND "TS"."CONTENTS$"=0 AND "TS"."BITMAPPED"<>0))
29 - filter("TS"."BITMAPPED"=0)
32 - access("TS"."TS#"="U"."TS#")
33 - access("U"."TS#"="FI"."TS#" AND "U"."SEGFILE#"="FI"."RELFILE#")
34 - access("U"."TS#"="RB"."TS#")
35 - filter(("U"."SEGFILE#"="RB"."FILE#" AND "U"."SEGBLOCK#"="RB"."BLOCK#"))


SQL> purge dba_recyclebin;
SQL> SELECT TABLESPACE_NAME, SUM(BYTES) / 1024 / 1024/ 1024 FREE_SPACE
FROM DBA_FREE_SPACE
GROUP BY TABLESPACE_NAME;

SQL> select * from table(dbms_xplan.display_cursor(null,null,'allstats last'));

PLAN_TABLE_OUTPUT
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
SQL_ID 81s4p9cv3060h, child number 0
-------------------------------------
SELECT TABLESPACE_NAME, SUM(BYTES) / 1024 / 1024/ 1024 FREE_SPACE
FROM DBA_FREE_SPACE GROUP BY TABLESPACE_NAME
-----------------------------------------------------------------------------------------------------------------------------------------
| Id | Operation | Name | Starts | E-Rows | A-Rows | A-Time | Buffers | OMem | 1Mem | Used-Mem |
-----------------------------------------------------------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1 | | 12 |00:00:00.18 | 2431 | | | |
| 1 | HASH GROUP BY | | 1 | 7 | 12 |00:00:00.18 | 2431 | 1903K| 1450K| 1103K (0)|
| 2 | VIEW | DBA_FREE_SPACE | 1 | 13208 | 13971 |00:00:00.18 | 2431 | | | |
| 3 | UNION-ALL | | 1 | | 13971 |00:00:00.18 | 2431 | | | |
| 4 | NESTED LOOPS | | 1 | 1 | 0 |00:00:00.01 | 19 | | | |
| 5 | NESTED LOOPS | | 1 | 1 | 0 |00:00:00.01 | 19 | | | |
| 6 | TABLE ACCESS CLUSTER | FET$ | 1 | 1 | 0 |00:00:00.01 | 19 | | | |
| 7 | INDEX FULL SCAN | I_TS# | 1 | 1 | 18 |00:00:00.01 | 1 | | | |
|* 8 | TABLE ACCESS CLUSTER | TS$ | 0 | 1 | 0 |00:00:00.01 | 0 | | | |
|* 9 | INDEX UNIQUE SCAN | I_TS# | 0 | 1 | 0 |00:00:00.01 | 0 | | | |
|* 10 | INDEX UNIQUE SCAN | I_FILE2 | 0 | 1 | 0 |00:00:00.01 | 0 | | | |
| 11 | NESTED LOOPS | | 1 | 13126 | 13971 |00:00:00.17 | 1864 | | | |
| 12 | NESTED LOOPS | | 1 | 13126 | 13971 |00:00:00.15 | 1860 | | | |
|* 13 | TABLE ACCESS CLUSTER | TS$ | 1 | 12 | 12 |00:00:00.01 | 19 | | | |
| 14 | INDEX FULL SCAN | I_TS# | 1 | 1 | 18 |00:00:00.01 | 1 | | | |
|* 15 | FIXED TABLE FIXED INDEX | X$KTFBFE (ind:1) | 12 | 1059 | 13971 |00:00:00.15 | 1841 | | | |
|* 16 | INDEX UNIQUE SCAN | I_FILE2 | 13971 | 1 | 13971 |00:00:00.01 | 4 | | | |
|* 17 | HASH JOIN | | 1 | 80 | 0 |00:00:00.01 | 529 | 1969K| 1969K| 360K (0)|
| 18 | NESTED LOOPS | | 1 | 84 | 0 |00:00:00.01 | 529 | | | |
|* 19 | HASH JOIN | | 1 | 5807 | 0 |00:00:00.01 | 529 | 1557K| 1557K| 496K (0)|
| 20 | TABLE ACCESS FULL | RECYCLEBIN$ | 1 | 5807 | 0 |00:00:00.01 | 529 | | | |
| 21 | FIXED TABLE FULL | X$KTFBUE | 0 | 100K| 0 |00:00:00.01 | 0 | | | |
|* 22 | INDEX UNIQUE SCAN | I_FILE2 | 0 | 1 | 0 |00:00:00.01 | 0 | | | |
|* 23 | TABLE ACCESS CLUSTER | TS$ | 0 | 12 | 0 |00:00:00.01 | 0 | | | |
| 24 | INDEX FULL SCAN | I_TS# | 0 | 1 | 0 |00:00:00.01 | 0 | | | |
| 25 | NESTED LOOPS | | 1 | 1 | 0 |00:00:00.01 | 19 | | | |
| 26 | NESTED LOOPS | | 1 | 968 | 0 |00:00:00.01 | 19 | | | |
| 27 | NESTED LOOPS | | 1 | 1 | 0 |00:00:00.01 | 19 | | | |
| 28 | NESTED LOOPS | | 1 | 1 | 0 |00:00:00.01 | 19 | | | |
|* 29 | TABLE ACCESS CLUSTER | TS$ | 1 | 1 | 0 |00:00:00.01 | 19 | | | |
| 30 | INDEX FULL SCAN | I_TS# | 1 | 1 | 18 |00:00:00.01 | 1 | | | |
| 31 | TABLE ACCESS CLUSTER | UET$ | 0 | 1 | 0 |00:00:00.01 | 0 | | | |
|* 32 | INDEX RANGE SCAN | I_FILE#_BLOCK# | 0 | 1 | 0 |00:00:00.01 | 0 | | | |
|* 33 | INDEX UNIQUE SCAN | I_FILE2 | 0 | 1 | 0 |00:00:00.01 | 0 | | | |
|* 34 | INDEX RANGE SCAN | RECYCLEBIN$_TS | 0 | 968 | 0 |00:00:00.01 | 0 | | | |
|* 35 | TABLE ACCESS BY INDEX ROWID| RECYCLEBIN$ | 0 | 2 | 0 |00:00:00.01 | 0 | | | |
-----------------------------------------------------------------------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
8 - filter("TS"."BITMAPPED"=0)
9 - access("TS"."TS#"="F"."TS#")
10 - access("F"."TS#"="FI"."TS#" AND "F"."FILE#"="FI"."RELFILE#")
13 - filter((INTERNAL_FUNCTION("TS"."ONLINE$") AND "TS"."CONTENTS$"=0 AND "TS"."BITMAPPED"<>0))
15 - filter("TS"."TS#"="F"."KTFBFETSN")
16 - access("F"."KTFBFETSN"="FI"."TS#" AND "F"."KTFBFEFNO"="FI"."RELFILE#")
17 - access("TS"."TS#"="RB"."TS#")
19 - access("U"."KTFBUESEGTSN"="RB"."TS#" AND "U"."KTFBUESEGFNO"="RB"."FILE#" AND "U"."KTFBUESEGBNO"="RB"."BLOCK#")
22 - access("RB"."TS#"="FI"."TS#" AND "U"."KTFBUEFNO"="FI"."RELFILE#")
23 - filter((INTERNAL_FUNCTION("TS"."ONLINE$") AND "TS"."CONTENTS$"=0 AND "TS"."BITMAPPED"<>0))
29 - filter("TS"."BITMAPPED"=0)
32 - access("TS"."TS#"="U"."TS#")
33 - access("U"."TS#"="FI"."TS#" AND "U"."SEGFILE#"="FI"."RELFILE#")
34 - access("U"."TS#"="RB"."TS#")
35 - filter(("U"."SEGFILE#"="RB"."FILE#" AND "U"."SEGBLOCK#"="RB"."BLOCK#"))

推荐阅读
  • 深入理解 SQL 视图、存储过程与事务
    本文详细介绍了SQL中的视图、存储过程和事务的概念及应用。视图为用户提供了一种灵活的数据查询方式,存储过程则封装了复杂的SQL逻辑,而事务确保了数据库操作的完整性和一致性。 ... [详细]
  • 构建基于BERT的中文NL2SQL模型:一个简明的基准
    本文探讨了将自然语言转换为SQL语句(NL2SQL)的任务,这是人工智能领域中一项非常实用的研究方向。文章介绍了笔者在公司举办的首届中文NL2SQL挑战赛中的实践,该比赛提供了金融和通用领域的表格数据,并标注了对应的自然语言与SQL语句对,旨在训练准确的NL2SQL模型。 ... [详细]
  • 在使用 DataGridView 时,如果在当前单元格中输入内容但光标未移开,点击保存按钮后,输入的内容可能无法保存。只有当光标离开单元格后,才能成功保存数据。本文将探讨如何通过调用 DataGridView 的内置方法解决此问题。 ... [详细]
  • 本文详细介绍了如何在 Linux 平台上安装和配置 PostgreSQL 数据库。通过访问官方资源并遵循特定的操作步骤,用户可以在不同发行版(如 Ubuntu 和 Red Hat)上顺利完成 PostgreSQL 的安装。 ... [详细]
  • 如何在PostgreSQL中查看数据表
    本文将指导您使用pgAdmin工具连接到PostgreSQL数据库,并展示如何浏览和查找其中的数据表。通过简单的步骤,您可以轻松访问所需的表结构和数据。 ... [详细]
  • 利用存储过程构建年度日历表的详细指南
    本文将介绍如何使用SQL存储过程创建一个完整的年度日历表。通过实例演示,帮助读者掌握存储过程的应用技巧,并提供详细的代码解析和执行步骤。 ... [详细]
  • 本文介绍了如何通过 Maven 依赖引入 SQLiteJDBC 和 HikariCP 包,从而在 Java 应用中高效地连接和操作 SQLite 数据库。文章提供了详细的代码示例,并解释了每个步骤的实现细节。 ... [详细]
  • 在使用SQL Server进行动态SQL查询时,如果遇到LIKE语句无法正确返回预期结果的情况,通常是因为参数传递方式不当。本文将详细探讨这一问题,并提供解决方案及相关的技术背景。 ... [详细]
  • 本文介绍如何通过创建替代插入触发器,使对视图的插入操作能够正确更新相关的基本表。涉及的表包括:飞机(Aircraft)、员工(Employee)和认证(Certification)。 ... [详细]
  • MySQL缓存机制深度解析
    本文详细探讨了MySQL的缓存机制,包括主从复制、读写分离以及缓存同步策略等内容。通过理解这些概念和技术,读者可以更好地优化数据库性能。 ... [详细]
  • SQLite 动态创建多个表的需求在网络上有不少讨论,但很少有详细的解决方案。本文将介绍如何在 Qt 环境中使用 QString 类轻松实现 SQLite 表的动态创建,并提供详细的步骤和示例代码。 ... [详细]
  • 精选30本C# ASP.NET SQL中文PDF电子书合集
    欢迎订阅我们的技术博客,获取更多关于C#、ASP.NET和SQL的最新资讯和资源。 ... [详细]
  • MySQL 数据库迁移指南:从本地到远程及磁盘间迁移
    本文详细介绍了如何在不同场景下进行 MySQL 数据库的迁移,包括从一个硬盘迁移到另一个硬盘、从一台计算机迁移到另一台计算机,以及解决迁移过程中可能遇到的问题。 ... [详细]
  • Hadoop入门与核心组件详解
    本文详细介绍了Hadoop的基础知识及其核心组件,包括HDFS、MapReduce和YARN。通过本文,读者可以全面了解Hadoop的生态系统及应用场景。 ... [详细]
  • 本文介绍如何在 FireDAC 环境下实现 FDMEMTable 字段的自动获取,为开发人员提供便捷的数据处理方式。 ... [详细]
author-avatar
红Lisa
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有