ورود

View Full Version : مقاله: ترجمه مقاله : Introduction to the Optimizer



رسول_57
یک شنبه 05 آذر 1391, 21:35 عصر
Overview of SQL Processing


SQL processing uses the following main components to execute a SQL query:


The Parser checks both syntax and semantic analysis.
The Optimizer uses costing methods, cost-based optimizer (CBO), or internal rules, rule-based optimizer (RBO), to determine the most efficient way of producing the result of the query.
The Row Source Generator receives the optimal plan from the optimizer and outputs the execution plan for the SQL statement.
The SQL Execution Engine operates on the execution plan associated with a SQL statement and then produces the results of the query.



Overview of the Optimizer


The optimizer determines the most efficient way to execute a SQL statement after considering many factors related to the objects referenced and the conditions specified in the query. This determination is an important step in the processing of any SQL statement and can greatly affect execution time.

A SQL statement can be executed in many different ways, including the following:


Full table scans
Index scans
Nested loops
Hash joins


Note:
The optimizer might not make the same decisions from one version of Oracle to the next. In recent versions, the optimizer might make different decisions, because better information is available.

The output from the optimizer is a plan that describes an optimum method of execution. The Oracle server provides the cost-based (CBO) and rule-based (RBO) optimization. In general, use the cost-based approach. Oracle Corporation is continually improving the CBO and new features require CBO.

Note: Oracle Corporation strongly advises the use of cost-based optimization. The rule-based optimization is available for backward compatibility with legacy applications and will be deprecated in a future release.


You can influence the optimizer's choices by setting the optimizer approach and goal, and by gathering representative statistics for the CBO. The optimizer goal is either throughput or response time. See "Choosing an Optimizer Approach and Goal" (http://docs.oracle.com/cd/B10500_01/server.920/a96533/optimops.htm#38183).

Sometimes, the application designer, who has more information about a particular application's data than is available to the optimizer, can choose a more effective way to execute a SQL statement. The application designer can use hints in SQL statements to specify how the statement should be executed.


Features that Require the CBO


The following features require use of the CBO:


Partitioned tables and indexes
Index-organized tables
Reverse key indexes
Function-based indexes
SAMPLE clauses in a SELECT statement
Parallel query and parallel DML
Star transformations and star joins
Extensible optimizer
Query rewrite with materialized views
Enterprise Manager progress meter
Hash joins
Bitmap indexes and bitmap join indexes
Index skip scans

مقدمه ای بر بهینه ساز اوراکل

مقدمه ای بر پردازش Sql

در پردازش کدهای SQL از اجزای زیر برای اجرای یک پرس و جو استفاده می گردد :
پارسر ، تحلیل های دستوری و معنایی را انجام می دهد .
بهینه سازی که از روش های ارزیابی هزینه استفاده می کند بهینه ساز مبتنی بر تخمین هزینه (CBO) و بهینه سازی که از قوانین داخلی خود استفاده می کند بهینه ساز مبتنی بر قوانین (RBO) نامیده می شود .
به منظور محاسبه کاراترین روش برای پاسخگویی به یک پرس و جو ، تولید کننده منبع سطر (Row Source Generator) ، طرح بهینه را از بهینه ساز دریافت کرده و طرح اجرایی را برای اجرای دستورات SQL تولید می کند.
موتور اجرای SQL ، براساس طرح اجرایی که دریافت می کند عملیات خود را انجام داده و نتایج پرس و جو را باز می گرداند .

مقدمه ای بر بهینه سازها

بهینه ساز ، با در نظر گرفتن بسیاری از فاکتورهای مرتبط با اشیای مربوطه و شرایط مشخص شده در پرس و جو ، کاراترین روش برای اجرای یک پرس و جوی SQL را محاسبه می کند . این محاسبه مهمترین قسمت در پردازش دستورات SQL است و به طور قابل توجهی بر زمان اجرا تاثیر دارد .
یک عبارت SQL به روش های مختلفی اجرا می گردد که شامل موارد زیر است :
*جستجوی کل جدول
*جستجوی ایندکس ها
*حلقه های تودرتو
*ترکیب های Hash
توجه داشته باشید که تصمیمات بهینه ساز در تمام نسخه های اوراکل ، یکسان نیست و در نسخه های جدیدتر اوراکل ، با توجه به اطلاعات بیشتری که موجود است تصمیمات متفاوتی گرفته می گردد .
خروجی بهینه ساز طرحی است که روش بهینه برای اجرا را نشان می دهد . سعی کنید تا حد امکان از روش بهینه سازی مبتنی بر هزینه استفاده کنید . شرکت اوراکل به صورت پیوسته در حال بهبود این روش بوده و همواره امکانات جدیدی به آن اضافه می کند . در نسخه های جدیدتر اوراکل تا حد امکان استفاده از روش بهینه سازی مبتنی بر قانون کاهش یافته است .
مدیر پایگاه داده حرفه ای با تنظیم روش و اهداف بهینه ساز و با جمع آوری آمارهای مورد نیاز می تواند بر تصمیمات بهینه ساز تاثیر بگذارد . هدف بهینه ساز می تواند بالا بردن کارهای همزمان و یا کاهش زمان اجرای عملیات باشد .
بعضی مواقع طراح برنامه های کاربردی که اطلاعات زیادی در مورد داده های یک برنامه خاص دارد ، می تواند بهترین روش را برای اجرای یک عبارت SQL انتخاب کند .

خصوصیاتی که به CBO نیاز دارند :

*جداول و ایندکس های پارتیشن بندی شده
*جداول سازماندهی شده براساس ایندکس
*ایندکس های کلید معکوس
*ایندکس های مبتنی بر تابع
*شرط های نمونه در دستورات Select
*دستورات کنترلی و پرس و جوهای موازی
*ترکیب های و تبدیل های ستاره ای
*بهینه ساز قابل توسعه
*پرس و جوهای بازنویسی شده با ویو های Materialized
*ارزیاب پیشرفت کنسول مدیریتی
*ترکیب های Hash
*ایندکس های بیت مپ و ترکیب بیت مپ
*جستو جوی های پرشی ایندکس