Quantcast
Channel: Toad for Oracle
Viewing all articles
Browse latest Browse all 4009

Wiki Page: SQL Optimization

$
0
0
This FAQ was adapted from a live-audience Q&A with Bert Scalzo following a webcast Q: Auto optimization ... Does it impact performance as it is actually running each alternative to get the run times? A: Sure - it runs original SQL and all the rewrites. You’ll do best to find the poorly performing SQL in production, then run and compare the original against the rewrites either in a test environment or during off hours. Q: If I understand your last illustrations, the optimization has made the queries run in less clock time and at a higher cost in CPU time? Is this true? A: Cost means nothing. Many people think low cost = best plan. It isn’t so. Often a low-cost plan takes longer to run than a higher-cost plan. So NEVER make SQL Optimization decisions based on explain plan cost alone. Read the blog post, “ The Hitchhiker’s Guide to the EXPLAIN PLAN Part 14: Damn the Cost, Full Speed Ahead. ” Q: What does Toad do with the bind variables in Auto Tune? A: The Auto Tune tries various SQL rewrites knowing that the bind variables can change; hence, the results can vary. So it will try some additional rewrites it would not have tried with hardcoded values in an attempt to provide better alternatives. Q: I do a lot of SQL optimization on DML queries. I have always been apprehensive of doing optimization on Toad since I do not know how to make sure that Toad does not actually execute the statement on the database. A: We offer options to do "what if" scenarios in a safe, sandboxed area. For example, I can try doing rewrites with new indexes you suggest, but not really create the indexes since that might goof things up while we're testing. Besides, Toad does not commit anything unless you hardcode a commit or press the commit key, so nothing is real unless you say make it so. Q: Does Auto Optimize actually run the SQL against the database, or does it just show suggestions? A: It runs original SQL and all the rewrites. You’ll do best to find the poorly performing SQL in production, then run and compare the original against the rewrites either in a test environment or during off hours. Q: can toad recommend specific hints? A: Yes. Auto Optimize and SQL Optimizer rewrite the SQL using different hints and/or different coding styles (e.g. sub select vs. JOIN). Toad also offers the ability to help you easily add hints. When you're in Editor, go to Main menu -> View -> Code Snippets, then choose Show hints in the Code Snippets drop-down. Now you can see all the possible Oracle hints, and drag-and-drop them into your code. Q: After tuning a SQL statement, shouldn't you run the original statement vs. the new statement to make sure you get the same population? A: We only offer SQL rewrites that return the same rows - period. Toad Auto Optimize and SQL Optimizer also let you choose whether those rows must be in the same sort order, or the same rows regardless of order. Q: One of the things I find is that sometimes the code cannot support hints. Can you change the optimization to not include hint changes? A: There are options to specify whether hints are allowed or forbidden in rewrite candidates. There are options for choosing only the hints that fit a specific type of workload nature, such as OLTP vs. DW. There are also options to select which of the possible 100+ Oracle hints you allow. Plus, the RAC and Exadata versions of the Toad bundle include hints specific to those platforms, such as smart scan and offloading. Q: Does SQL Optimizier fix SQL for OLAP also? A: Yes, we have limited support for OLAP. Q: Does SQL Optimizer provide table partitioning recommendations or detect deficiencies in database design? A: Yes. For example, there are utilities to examine the database table and index design and to make purely structural advice and/or recommendations, like partitioning the table or using a different type of index. There is also a utility to watch all the SQL hitting objects and offer workload-based advice and/or recommendations. Q: The second run of the query will be always faster, right? So do you clear the cache every time you run the SQL and look at the explain plan? A: There are options for setting the number of times to run the query so you can average the time. Other options let you control this as well, such as clearing the cache and limiting the run time (for examples, stop if reach 100% of original run time). Q: Would the Trace analyzer be enhanced to include the comprehensive details out of SQLT? A: This is on our roadmap. Q: If you have to use FTP to load a trace file, how do you determine the correct path to the trace file? A: Voodoo black magic :) Just kidding. If you started and stopped the trace using the Toad session browser than we know the trace file location and name. Otherwise, you will need to know and provide the information.

Viewing all articles
Browse latest Browse all 4009

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>