获取数据库30天内各个指标的TOP语句
要查询短时间内的可以从v$sql 或者是v$sqlarea 如果要查询一周或者一个月内 那么有可能在V$SQLAREA里找不到!下面是通过历史DBA_HIST_SQLSTAT里获得, 这个是通过快照方式保留下来的. --执行时间最长的 WITH BASTABLE AS ( SELECT DBMS_LOB.SUBSTR(SQL_TEXT,40
要查询短时间内的可以从v$sql 或者是v$sqlarea 如果要查询一周或者一个月内 那么有可能在V$SQLAREA里找不到!下面是通过历史DBA_HIST_SQLSTAT里获得, 这个是通过快照方式保留下来的.
--执行时间最长的
WITH BASTABLE AS
(
SELECT DBMS_LOB.SUBSTR(SQL_TEXT,4000, 1 ) AS SQL_FULL_TEXT,
DHST.SQL_ID,
ROUND (X.ELAPSED_TIME / 1000000 / X.EXECUTIONS_DELTA, 3) AVG_ELAPSED_TIME_SEC,
ROUND (X.CPU_TIME / 1000000 / X.EXECUTIONS_DELTA, 3) AVG_CPU_TIME_SEC,
ROUND (X.BUFFER_GETS_DELTA / X.EXECUTIONS_DELTA, 3) AVG_BUFFER_GETS,
ROUND (X.PARSE_CALLS_DELTA/X.EXECUTIONS_DELTA*100, 3) EXEC_PARSE_RATE,
ROUND (X.PHYSICAL_READ_BYTES_DELTA/1024/X.EXECUTIONS_DELTA, 3) AVG_PHYSICAL_READ_KB,
ROUND (X.DISK_READS_DELTA / X.EXECUTIONS_DELTA, 3) AVG_DISK_READS,
EXECUTIONS_DELTA AS EXEC_TOTAL_NUM,DHST.COMMAND_TYPE,N.COMMAND_NAME
FROM DBA_HIST_SQLTEXT DHST, DBA_HIST_SQLCOMMAND_NAME N,
(
SELECT DHSS.SQL_ID SQL_ID,
SUM (DHSS.CPU_TIME_DELTA) CPU_TIME,
SUM (DHSS.ELAPSED_TIME_DELTA) ELAPSED_TIME,
CASE SUM (DHSS.EXECUTIONS_DELTA) WHEN 0 THEN 1 ELSE SUM (DHSS.EXECUTIONS_DELTA) END AS EXECUTIONS_DELTA,
CASE SUM (DHSS.SORTS_DELTA) WHEN 0 THEN 1 ELSE SUM (DHSS.SORTS_DELTA) END AS SORTS_DELTA,
CASE SUM (DHSS.FETCHES_DELTA) WHEN 0 THEN 1 ELSE SUM (DHSS.FETCHES_DELTA) END AS FETCHES_DELTA,
CASE SUM (DHSS.PARSE_CALLS_DELTA) WHEN 0 THEN 1 ELSE SUM (DHSS.PARSE_CALLS_DELTA) END AS PARSE_CALLS_DELTA,
CASE SUM (DHSS.DISK_READS_DELTA) WHEN 0 THEN 1 ELSE SUM (DHSS.DISK_READS_DELTA) END AS DISK_READS_DELTA,
CASE SUM (DHSS.BUFFER_GETS_DELTA) WHEN 0 THEN 1 ELSE SUM (DHSS.BUFFER_GETS_DELTA) END AS BUFFER_GETS_DELTA,
CASE SUM (DHSS.IOWAIT_DELTA) WHEN 0 THEN 1 ELSE SUM (DHSS.IOWAIT_DELTA) END AS IOWAIT_DELTA,
CASE SUM (DHSS.PHYSICAL_READ_BYTES_DELTA) WHEN 0 THEN 1 ELSE SUM (DHSS.PHYSICAL_READ_BYTES_DELTA) END AS PHYSICAL_READ_BYTES_DELTA
FROM DBA_HIST_SQLSTAT DHSS
WHERE DHSS.SNAP_ID IN
(SELECT SNAP_ID
FROM DBA_HIST_SNAPSHOT
WHERE BEGIN_INTERVAL_TIME >= TRUNC(SYSDATE)-30
AND END_INTERVAL_TIME
AND DHSS.PARSING_SCHEMA_NAME =UPPER('SHARK')
GROUP BY DHSS.SQL_ID
) X
WHERE X.SQL_ID = DHST.SQL_ID
AND DHST.COMMAND_TYPE = N.COMMAND_TYPE
)
SELECT * FROM
(
SELECT SQL_FULL_TEXT,SQL_ID,EXEC_TOTAL_NUM, AVG_DISK_READS AS VALUE_S, 'AVG_DISK_READS' AS VALUES_TYPE
FROM BASTABLE WHERE COMMAND_TYPE47 AND SQL_FULL_TEXT NOT LIKE '/* SQL A%' ORDER BY AVG_DISK_READS DESC ) WHERE ROWNUM
UNION ALL
SELECT * FROM
(
SELECT SQL_FULL_TEXT,SQL_ID,EXEC_TOTAL_NUM, AVG_ELAPSED_TIME_SEC AS VALUE_S, 'AVG_ELAPSED_TIME_SEC' AS VALUES_TYPE
FROM BASTABLE WHERE COMMAND_TYPE47 AND SQL_FULL_TEXT NOT LIKE '/* SQL A%' ORDER BY AVG_ELAPSED_TIME_SEC DESC ) WHERE ROWNUM
UNION ALL
SELECT * FROM
(
SELECT SQL_FULL_TEXT,SQL_ID,EXEC_TOTAL_NUM, AVG_CPU_TIME_SEC AS VALUE_S, 'AVG_CPU_TIME_SEC' AS VALUES_TYPE
FROM BASTABLE WHERE COMMAND_TYPE47 AND SQL_FULL_TEXT NOT LIKE '/* SQL A%' ORDER BY AVG_CPU_TIME_SEC DESC ) WHERE ROWNUM
UNION ALL
SELECT * FROM
(
SELECT SQL_FULL_TEXT,SQL_ID,EXEC_TOTAL_NUM, AVG_BUFFER_GETS AS VALUE_S, 'AVG_BUFFER_GETS' AS VALUES_TYPE
FROM BASTABLE WHERE COMMAND_TYPE47 AND SQL_FULL_TEXT NOT LIKE '/* SQL A%' ORDER BY AVG_BUFFER_GETS DESC ) WHERE ROWNUM
UNION ALL
SELECT * FROM
(
SELECT SQL_FULL_TEXT,SQL_ID,EXEC_TOTAL_NUM, EXEC_PARSE_RATE AS VALUE_S, 'EXEC_PARSE_RATE' AS VALUES_TYPE
FROM BASTABLE WHERE COMMAND_TYPE47 AND SQL_FULL_TEXT NOT LIKE '/* SQL A%' ORDER BY EXEC_PARSE_RATE DESC ) WHERE ROWNUM
UNION ALL
SELECT * FROM
(
SELECT SQL_FULL_TEXT,SQL_ID,EXEC_TOTAL_NUM, AVG_PHYSICAL_READ_KB AS VALUE_S, 'AVG_PHYSICAL_READ_KB' AS VALUES_TYPE
FROM BASTABLE WHERE COMMAND_TYPE47 ORDER BY AVG_PHYSICAL_READ_KB DESC ) WHERE ROWNUM
UNION ALL
SELECT * FROM
(
SELECT SQL_FULL_TEXT,SQL_ID,EXEC_TOTAL_NUM, EXEC_TOTAL_NUM AS VALUE_S, 'EXEC_TOTAL_NUM' AS VALUES_TYPE
FROM BASTABLE WHERE COMMAND_TYPE47 AND SQL_FULL_TEXT NOT LIKE '/* SQL A%' ORDER BY EXEC_TOTAL_NUM DESC ) WHERE ROWNUM
UNION ALL
SELECT * FROM
(
SELECT SQL_FULL_TEXT,SQL_ID,EXEC_TOTAL_NUM, AVG_ELAPSED_TIME_SEC AS VALUE_S, 'PROCEDURES_EXEC_TIME' AS VALUES_TYPE
FROM BASTABLE WHERE COMMAND_TYPE=47 AND SQL_FULL_TEXT NOT LIKE '/* SQL A%' ORDER BY AVG_ELAPSED_TIME_SEC DESC ) WHERE ROWNUM

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

Download the latest version of 12306 ticket booking app. It is a travel ticket purchasing software that everyone is very satisfied with. It is very convenient to go wherever you want. There are many ticket sources provided in the software. You only need to pass real-name authentication to purchase tickets online. All users You can easily buy travel tickets and air tickets and enjoy different discounts. You can also start booking reservations in advance to grab tickets. You can book hotels or special car transfers. With it, you can go where you want to go and buy tickets with one click. Traveling is simpler and more convenient, making everyone's travel experience more comfortable. Now the editor details it online Provides 12306 users with a way to view historical ticket purchase records. 1. Open Railway 12306, click My in the lower right corner, and click My Order 2. Click Paid on the order page. 3. On the paid page

How to check my academic qualifications on Xuexin.com? You can check your academic qualifications on Xuexin.com, but many users don’t know how to check their academic qualifications on Xuexin.com. Next, the editor brings you a graphic tutorial on how to check your academic qualifications on Xuexin.com. Interested users come and take a look! Xuexin.com usage tutorial: How to check your academic qualifications on Xuexin.com 1. Xuexin.com entrance: https://www.chsi.com.cn/ 2. Website query: Step 1: Click on the Xuexin.com address above to enter the homepage Click [Education Query]; Step 2: On the latest webpage, click [Query] as shown by the arrow in the figure below; Step 3: Then click [Login Academic Credit File] on the new page; Step 4: On the login page Enter the information and click [Login];

Google Authenticator is a tool used to protect the security of user accounts, and its key is important information used to generate dynamic verification codes. If you forget the key of Google Authenticator and can only verify it through the security code, then the editor of this website will bring you a detailed introduction on where to get the Google security code. I hope it can help you. If you want to know more Users please continue reading below! First open the phone settings and enter the settings page. Scroll down the page and find Google. Go to the Google page and click on Google Account. Enter the account page and click View under the verification code. Enter your password or use your fingerprint to verify your identity. Obtain a Google security code and use the security code to verify your Google identity.

Go language is an efficient, concise and easy-to-learn programming language. It is favored by developers because of its advantages in concurrent programming and network programming. In actual development, database operations are an indispensable part. This article will introduce how to use Go language to implement database addition, deletion, modification and query operations. In Go language, we usually use third-party libraries to operate databases, such as commonly used sql packages, gorm, etc. Here we take the sql package as an example to introduce how to implement the addition, deletion, modification and query operations of the database. Assume we are using a MySQL database.

Hibernate polymorphic mapping can map inherited classes to the database and provides the following mapping types: joined-subclass: Create a separate table for the subclass, including all columns of the parent class. table-per-class: Create a separate table for subclasses, containing only subclass-specific columns. union-subclass: similar to joined-subclass, but the parent class table unions all subclass columns.

Apple's latest releases of iOS18, iPadOS18 and macOS Sequoia systems have added an important feature to the Photos application, designed to help users easily recover photos and videos lost or damaged due to various reasons. The new feature introduces an album called "Recovered" in the Tools section of the Photos app that will automatically appear when a user has pictures or videos on their device that are not part of their photo library. The emergence of the "Recovered" album provides a solution for photos and videos lost due to database corruption, the camera application not saving to the photo library correctly, or a third-party application managing the photo library. Users only need a few simple steps

HTML cannot read the database directly, but it can be achieved through JavaScript and AJAX. The steps include establishing a database connection, sending a query, processing the response, and updating the page. This article provides a practical example of using JavaScript, AJAX and PHP to read data from a MySQL database, showing how to dynamically display query results in an HTML page. This example uses XMLHttpRequest to establish a database connection, send a query and process the response, thereby filling data into page elements and realizing the function of HTML reading the database.

How to use MySQLi to establish a database connection in PHP: Include MySQLi extension (require_once) Create connection function (functionconnect_to_db) Call connection function ($conn=connect_to_db()) Execute query ($result=$conn->query()) Close connection ( $conn->close())
