简体   繁体   中英

Performance Tuning

How can i check the Query running from long time & steps of tuning the query? (Oracle)

  1. Run explain plan for select .... to see what Oracle is doing with your query.
  2. Post your query here so that we can look at it and help you out.
  3. Check out the Oracle Performance Tuning FAQ for some tricks-of-the-trade, if you will.

You can capture the query by selecting from v$sql or v$sqltext. If you are not familiar with it, look up 'Explain Plan' in the Oracle documentation. There should be plenty on it in the performance tuning guide.

Have a look at Quest Software's Toad for a third party tool that helps in this area too.

K

Unfortunately your question is not expressed clearly. The other answers have already tackled the issue of tuning a known bad query, but another interpretation is that you want to monitor your database to find poorly performing queries.

If you don't have Enterprise Edition with the Diagnostics pack - and not many of us do - your best bet is to run statspack snapshots on a reqular basis. This will give you a lot of information about your system, including which queries take a long time to complete and which queries consume a lot of your system's resources. You can find out more about statspack here .

If you do not want to use OEM, then you can query and find out.

  1. First find the long running query. If it's currently being executing, You can join gv$session to find which session running since long time. Then go to gv$sql to find SQL details. You need to look last_call_et column.If SQL executed some time inpast you can use dba_hist_snapshot ,dba_hist_sqlstat ,DBA_HIST_SQLTEXT tables to find offending SQL.

  2. Once you get query, you can check what plan it's picking from dba_hist_sql_plan table if this SQL executed in past or from gv$sql_plan if it's currently executing.

  3. Now you analyze execution plan and see if it's using right index, join etc. If not tune those.

Let me know which step you have the problem. I can help you in answering those.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM