返回顶部
首页 > 资讯 > 数据库 >select count(*) from v$lock 查询慢
  • 535
分享到

select count(*) from v$lock 查询慢

2024-04-02 19:04:59 535人浏览 安东尼
摘要

描述:select count(*) from v$lock 查询慢 解决方法,具体原因看官方优化文档哈 sql> set time on 00:51:52 SQL> selec&

描述:
select count(*) from v$lock 查询慢 解决方法,具体原因看官方优化文档哈

sql> set time on 
00:51:52 SQL> select count(*) from v$lock;

  COUNT(*)
----------
        35
--需要十几秒才能返回结果。

00:55:10 SQL> select  count(*) from v$lock;

  COUNT(*)
----------
        35

00:55:38 SQL> 

方法1:
添加hint
方法2:
收集统计信息

MOS参考文档
Query Against v$lock Run from OEM PerfORMs Slowly (文档 ID 1328789.1)

搜集统计信息方法如下:
13.2.5 Gathering Statistics for Fixed Objects
Fixed objects are dynamic performance tables and their indexes. These objects record current database activity.
Unlike other database tables, the database does not automatically use dynamic statistics for SQL statement referencing X$ tables when optimizer statistics are missing. Instead, the optimizer uses predefined default values. These defaults may not be representative and could potentially lead to a suboptimal execution plan. Thus, it is important to keep fixed object statistics current.
oracle Database automatically gathers fixed object statistics as part of automated statistics gathering if they have not been previously collected. You can also manually collect statistics on fixed objects by calling DBMS_STATS.GATHER_FIXED_OBJECTS_STATS. Oracle recommends that you gather statistics when the database has representative activity.

Prerequisites
You must have the SYSDBA or ANALYZE ANY DICTIONARY system privilege to execute this procedure.

To gather schema statistics using GATHER_FIXED_OBJECTS_STATS:
In SQL*Plus or SQL Developer, log in to the database as a user with the necessary privileges.

Example 13-2 Gathering Statistics for a Table
This example uses the DBMS_STATS package to gather fixed object statistics.

BEGIN
  DBMS_STATS.GATHER_FIXED_OBJECTS_STATS;
END;
/

See Also:
"Configuring Automatic Optimizer Statistics Collection"
Oracle Database PL/SQL Packages and Types Reference to learn about the GATHER_TABLE_STATS procedure
Parent topic: Gathering Optimizer Statistics Manually
您可能感兴趣的文档:

--结束END--

本文标题: select count(*) from v$lock 查询慢

本文链接: https://lsjlt.com/news/41628.html(转载时请注明来源链接)

有问题或投稿请发送至: 邮箱/279061341@qq.com    QQ/279061341

猜你喜欢
软考高级职称资格查询
编程网,编程工程师的家园,是目前国内优秀的开源技术社区之一,形成了由开源软件库、代码分享、资讯、协作翻译、讨论区和博客等几大频道内容,为IT开发者提供了一个发现、使用、并交流开源技术的平台。
  • 官方手机版

  • 微信公众号

  • 商务合作