System JAVA, SQL performance optimization

 

 

Query the number of executions of a statement:

SELECT SQL_ID, SQL_TEXT,FIRST_LOAD_TIME, EXECUTIONS

   FROM V$SQLAREA 

   WHERE SQL_TEXT LIKE '%UPDATE %' and EXECUTIONS > 100000 

    ORDER BY EXECUTIONS 

   

 

View the most frequently executed SQL in the current database. For example, query the most frequently executed TOP 15 SQL statements:

SELECT SQL_TEXT, EXECUTIONS

  FROM (SELECT SQL_TEXT,

               EXECUTIONS,

               RANK() OVER(ORDER BY EXECUTIONS DESC) EXEC_RANK

          FROM V$SQLAREA)

 WHERE EXEC_RANK <= 15;

 

The following sentence lists the sql whose cpu_time occupies top 10

select cpu_time,sql_text

from (select sql_text,cpu_time,

rank() over (order by cpu_time desc) exec_rank

from v$sql

      )

where exec_rank <=10;

 

The top 10 most executed

select sql_text,executions

from (select sql_text,executions,

    rank() over

     (order by executions desc) exec_rank

    from v$sql)

where exec_rank <=10;

 

 

 

6. The ratio of the top 10 statements that waste the most memory to all statements

Without tuning, the 10 most commonly used SQL statements in most systems accounted for more than 50% of the memory read operations in the entire system. This section measures the severity of the harm done to the overall system by the code that affects the most performance, expressed as a percentage (less than 5% is optimal).

select sum(pct_bufgets) "Percent" from (select rank() over ( order by buffer_gets desc ) as rank_bufgets,to_char(100 * ratio_to_report(buffer_gets) over (),'999.99') pct_bufgets from v$sqlarea ) where rank_bufgets < 11;

 

7. Adjust the main statement of abusing disk read operations

I've found that without tuning, on most systems, disk reads for the top 25 most accessed statements would take up to 75% of all disk and/or memory reads across the system.

select disk_reads, substr(sql_text,1,4000) from v$sqlarea  order by disk_reads desc;

 

 

2. Find the SQL with the most disk reads and writes:

SQL>SELECT * FROM

   (SELECT sql_text,disk_reads "total disk" , executions "total exec",disk_reads/executions "disk/exec" FROM v$sql WHERE executions>0 and is_obsolete='N' ORDER BY 4 desc)

   WHERE ROWNUM<11 ;

 

 

http://www.xuebuyuan.com/2210903.html

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326462903&siteId=291194637