Home > Oracle Database / Applications Tips > Chapter excerpts from Oracle books > Oracle SQL and index internals: High performing SQL -- where do you start?
Oracle Tips:
EMAIL THIS
 TIPS & NEWSLETTERS TOPICS 

CHAPTER EXCERPTS FROM ORACLE BOOKS

Oracle SQL and index internals: High performing SQL -- where do you start?


Kimberly Floss
06.14.2004
Rating: -3.00- (out of 5)


Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   


The following is the first part of a 12-part series on Oracle10g CBO internals and SQL tuning optimization. Each tip is excerpted from the not-yet-released Rampant TechPress book, "Oracle SQL and index internals," by Kimberly Floss. Check back to the main series page for upcoming installments.


High performing SQL -- where do you start?

Once you know all the things that can be tuned, within the database, where do you start? The answer is, with the code. You can double check all the init.ora parameters to start, monitor hit ratios and use operating system monitoring tools, but most often, the issue is in the code. Both Oracle9i and Oracle10g have added many new features to assist in tuning SQL to make it run faster. We've already covered some of the major Oracle10g new functionality, including ADDM, and the advisors.

Before you can start tuning, you need to understand your goals. Oracle has several types of indexes (b-tree, bitmap) all designed to speed-up data retrieval. Index access can be faster than a full-table scan especially when the desired result set is small and when the rows are on adjacent data blocks (as defined by the clustering_factor column of the dba_indexes view). In certain cases (i.e., a large sorted result set), index access can be more expensive (in terms of logical I/O's) than a full-table scan, but it will start to deliver rows to the requesting program very quickly. Therefore, in order to tune, you need to decide your destination:

  • Minimize computing resources: This is Oracle's all_rows optimizer_mode, whereby the CBO strives to deliver the desired rows with a minimum of computing resources. The all_rows optimizer_mode gives a lower cost to parallel full-table scans.
  • Minimize response time: When the goal is to minimize response time, Oracle's first_rows optimizer_mode is ideal. The first_rows optimizer_mode gives a lower relative weight to index scans, thereby favoring access plans that start returning rows very quickly, even if it means more logical I/O operations and more computing resources. Being flexible, Oracle provides a wealth of optimizer parameters to allow the senior Oracle DBA to change the default behavior of the CBO.

For example, the optimizer_index_cost_adj parameter is used to control the relative weight assigned to index scans. For most databases, the CBO does an excellent job of always choosing the most appropriate access method for the query.

The characteristics of the data have a huge bearing on the CBO's choice of execution plans. These metadata items include:

  • Size of the table, partitioning of table
  • Number of distinct values within each table column
  • Distribution of values (skew) of table columns (from dba_histogram_cols)
  • Availability of parallel query servers (from cpu_count)
  • Clustering of data rows on data blocks (clustering_factor column in dba_indexes)
  • And many, many more

The CBO only makes intelligent decisions when it is provided with accurate metadata statistics. For years, the CBO has been viewed as 'potentially problematic,' when in fact, it is the lack of accurate and current statistics that have been the real issue.

Go to the main series page.


About the authors

Kimberly Floss is one of the most-respected Oracle database administrators in the U.S., and is president of the International Oracle Users Group (IOUG). With more than a decade of experience, Kimberly specializes in Oracle performance tuning and is a respected expert in SQL tuning techniques. She is an active member of the Chicago Oracle Users Group, and the Midwest Oracle Users Group, in addition to the IOUG. Kimberly Floss has over 15 years of experience in the information technology industry, with specific focus on relational database technology, including Oracle, DB2, Microsoft SQL Server and Sybase. She holds a bachelor's of science degree in computer information systems from Purdue University, specializing in systems analysis and design, and has an MBA with emphasis in management information systems from Loyola University.

Rate this Tip
To rate tips, you must be a member of SearchOracle.com.
Register now to start rating these tips. Log in if you are already a member.




Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   



RELATED CONTENT
Chapter excerpts from Oracle books
Writing single-row and multiple-row subqueries
List the types of SQL subqueries
Using subqueries in SQL
Define SQL subqueries
Oracle 11g: PL/SQL Basics
Oracle 11g: Backup and recovery concepts
Migrating to Oracle: Expert Secrets to Migrate from SQL Server and MySQL
Oracle Database 11g SQL Tuning
Upgrading to Oracle Database 11g
Tuning the Oracle database with initialization parameters

RELATED RESOURCES
2020software.com, trial software downloads for accounting software, ERP software, CRM software and business software systems
Search Bitpipe.com for the latest white papers and business webcasts
Whatis.com, the online computer dictionary

DISCLAIMER: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.



Oracle Development Solutions - SQL, J2EE, XML, SOA
HomeNewsTopicsTipsAsk the ExpertsMultimediaWhite PapersProductsBlogs
About Us  |  Contact Us  |  For Advertisers  |  For Business Partners  |  Site Index  |  RSS
SEARCH 
TechTarget provides technology professionals with the information they need to perform their jobs - from developing strategy, to making cost-effective purchase decisions and managing their organizations' technology projects - with its network of technology-specific websites, events and online magazines.

TechTarget Corporate Web Site  |  Media Kits  |  Site Map




All Rights Reserved, Copyright 2003 - 2009, TechTarget | Read our Privacy Policy
  TechTarget - The IT Media ROI Experts