Sep 27, 2017

When your query takes too long to execute ...

What to do when your query is too slow? Why it is slow. What is the real cause of your problem?

If the reason why is not known, suggesting to rewrite the query, or hinting the query, suggesting parallellization et cetera is not very productive. Once in a while you may get lucky. But even then you have to realize that if your problem seems "solved", but you don't know why, nothing guarantees you that the problem won't come back tomorrow. So the first step should always be to investigate the root cause.

The tools at your disposal are, among more:
- dbms_profiler
- explain plan
- SQL*Trace / tkprof
- AWR
- SQLT report

dbms_profiler:

Use dbms_profiler if you want to know where time is being spent in PL/SQL code. Statspack is a must if you are a dba and want to know what is going on in your entire database. For a single query or a small process, explain plan and SQL*Trace and tkprof are your tools.

Click here to read more about dbms_profiler and its issues...

Explain Plan:

The EXPLAIN PLAN statement displays execution plans chosen by the Oracle optimizer for SELECT, UPDATE, INSERT, and DELETE statements. A statement's execution plan is the sequence of operations Oracle performs to run the statement.

in SQL*Plus you have to type:
explain plan for <your query>;
select * from table(dbms_xplan.display);

When you get error messages or a message complaining about an old version of plan_table, make sure you run the script utlxplan.sql.

The output you get here basically shows you what the cost based optimizer expects. It gives you an idea on why the cost based optimizer chooses an access path.

Click here to read more about explain plan...

SQL*Trace/tkprof:

For this you have to type in SQL*Plus:
- alter session set sql_trace true;
- <run your query>;
- disconnect (this step is important, because it ensures all cursors get closed, and "row source operation" is generated)
- identify your trace file in the server directory as specified in the parameter user_dump_dest
- on your operating system: tkprof <trace file> q_out.txt sys=no sort=prsela exeela fchela

The file a.txt will now give you valuable information on what has actually happened. No predictions but the truth.

By comparing the output from explain plan with the output from tkprof, you are able to identify the possible problem areas.

Click here to read more about SQL*Trace and tkprof...

Analyze AWR report:

As you have Generated AWR Report in Oracle, Next task is to Analyze AWR Report in Oracle. By Reading AWR Report  you can easily solve issues like Slow database, high wait events, Slow query and many more. Though It's a lengthy report but Analyzing or Reading relevant part of AWR Report can help to troubleshoot issues in easy and fast manner.

AWR stands for Automatically workload repository, Though there could be many types of database performance issues, but when whole database is slow, then there are two possibilities.

Click here to read more about how to analyze AWR reports...

Note: You can follow so many blogs and other oracle documents also.

SQLT Report:

SQLT, also known as SQLTXPLAIN is a tool provided by Oracle Server Technologies Center of Expertise that can be used to diagnose why a particular SQL statement is performing poorly.  It is not like AWR or Statspack which provide a system-wide view of performance.  SQLT is very focused and works on one SQL statement at a time.  SQLT inputs one SQL statement and outputs a set of diagnostics files. These files can be used to diagnose SQL statements performing poorly.  In this blog, I will give an overview of SQLT and how to get started with it.

Click here to read more about sqlt reports...



37 comments:

  1. Thanks for sharing this Oracle Database blog. It is really helpful, Continue sharing more like this.
    Oracle Training in Chennai | Oracle course in Chennai | Oracle DBA Training in Chennai

    ReplyDelete
  2. I have to voice my passion for your kindness giving support to those people that should have guidance on this important matter.
    fire and safety course in chennai

    ReplyDelete
  3. I enjoy what you guys are usually up too. This sort of clever work and coverage! Keep up the wonderful works guys I’ve added you guys to my blog roll.\
    fire and safety course in chennai

    ReplyDelete
  4. This comment has been removed by a blog administrator.

    ReplyDelete
  5. Hey, would you mind if I share your blog with my twitter group? There’s a lot of folks that I think would enjoy your content. Please let me know. Thank you.
    Java Training in Chennai | J2EE Training in Chennai | Advanced Java Training in Chennai | Core Java Training in Chennai | Java Training institute in Chennai

    ReplyDelete
  6. Nice blog Post ! This post contains very informative and knowledgeable. oracle training in chennai

    ReplyDelete
  7. Wow it is really wonderful and awesome thus it is very much useful for me to understand many concepts and helped me a lot. it is really explainable very well and i got more information from your blog.
    Java Training in Chennai

    Java Training in Velachery

    Java Training inTambaram

    Java Training in Porur

    Java Training in Omr

    Java Training in Annanagar

    ReplyDelete
  8. What a great article!. Your posts is really helpful for me. Thanks for your wonderful post. I am very happy to read your post

    Java Training in Chennai

    Java Course in Chennai

    ReplyDelete
  9. Deep Learning Projects assist final year students with improving your applied Deep Learning skills rapidly while allowing you to investigate an intriguing point. Furthermore, you can include Deep Learning projects for final year into your portfolio, making it simpler to get a vocation, discover cool profession openings,
    Oracle DBA Training in Bangalore

    ReplyDelete
  10. This comment has been removed by a blog administrator.

    ReplyDelete
  11. This comment has been removed by a blog administrator.

    ReplyDelete
  12. This comment has been removed by a blog administrator.

    ReplyDelete
  13. very informative blogs posting thanks you so much sharing me information.
    German Language Course In Chandigarh

    ReplyDelete
  14. This comment has been removed by a blog administrator.

    ReplyDelete
  15. This post is so interactive and informative.keep update more information...
    ccna Training in Tambaram
    ccna course in Chennai

    ReplyDelete
  16. very informative blogs posting thanks you so much sharing me information.
    if you are looking for zirconia crowns in india. then you can visit dental direkt india, which is best zirconia provider in india

    ReplyDelete
  17. Thank you so much for such a well-written article. It’s full of insightful information
    Best Zirconia Brands In India

    ReplyDelete
  18. Thank you so much for such a well-written article. It’s full of insightful information
    if you are looking for best zirconia crowns in india. then you can visit dental direkt india, which is best zirconia provider in india

    ReplyDelete
  19. I really appreciate the kind of topics you post here, a great information that is actually helpful for us and you can also visit our link for best zirconia crowns in india

    ReplyDelete
  20. This comment has been removed by a blog administrator.

    ReplyDelete
  21. This comment has been removed by a blog administrator.

    ReplyDelete
  22. This comment has been removed by a blog administrator.

    ReplyDelete
  23. This comment has been removed by a blog administrator.

    ReplyDelete
  24. This comment has been removed by a blog administrator.

    ReplyDelete
  25. This comment has been removed by a blog administrator.

    ReplyDelete
  26. This comment has been removed by a blog administrator.

    ReplyDelete
  27. This comment has been removed by the author.

    ReplyDelete
  28. very well explained.thanks for sharing such a informative post.
    SQL course in Pune

    ReplyDelete
  29. great, valuable post , i have learned many intresting thing about sql from your blog, thanks . keep posting and checking out my blog if your intresting in python course in satara

    ReplyDelete

Translate >>