Home > Database > Oracle > How does oracle slow query?

How does oracle slow query?

coldplay.xixi
Release: 2020-07-17 16:01:27
Original
5224 people have browsed it

Oracle slow query method: 1. The SQL with the slowest query execution, the code is [on sa.PARSING_USER_ID = u.user_id]; 2. The SQL with the most queries, the code is [on u.USER_ID = s.PARSING_USER_ID) t].

How does oracle slow query?

Oracle slow query method:

Oracle does not set parameters to analyze slow queries at the same time like MySql does, however However, it provides a slow query sql statement. This sql statement needs to be logged in with an account with dba authority to query.

1. The sql with the slowest query execution

select *
 from (select sa.SQL_TEXT,
        sa.SQL_FULLTEXT,
        sa.EXECUTIONS "执行次数",
        round(sa.ELAPSED_TIME / 1000000, 2) "总执行时间",
        round(sa.ELAPSED_TIME / 1000000 / sa.EXECUTIONS, 2) "平均执行时间",
        sa.COMMAND_TYPE,
        sa.PARSING_USER_ID "用户ID",
        u.username "用户名",
        sa.HASH_VALUE
     from v$sqlarea sa
     left join all_users u
      on sa.PARSING_USER_ID = u.user_id
     where sa.EXECUTIONS > 0 where u.username='填写同户名'
     order by (sa.ELAPSED_TIME / sa.EXECUTIONS) desc)
 where rownum <= 50;#查询的数据数目
Copy after login

2. The sql with the most queries

select *
 from (select s.SQL_TEXT,
        s.EXECUTIONS "执行次数",
        s.PARSING_USER_ID "用户名",
        rank() over(order by EXECUTIONS desc) EXEC_RANK
     from v$sql s
     left join all_users u
      on u.USER_ID = s.PARSING_USER_ID) t
 where exec_rank <= 100;
Copy after login

Related learning recommendations: oracle database learning tutorial

The above is the detailed content of How does oracle slow query?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template