<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="de">
	<id>http://robopagex.com/index.php?action=history&amp;feed=atom&amp;title=SQL_TUNING</id>
	<title>SQL TUNING - Versionsgeschichte</title>
	<link rel="self" type="application/atom+xml" href="http://robopagex.com/index.php?action=history&amp;feed=atom&amp;title=SQL_TUNING"/>
	<link rel="alternate" type="text/html" href="http://robopagex.com/index.php?title=SQL_TUNING&amp;action=history"/>
	<updated>2026-04-30T16:08:47Z</updated>
	<subtitle>Versionsgeschichte dieser Seite in robopagex.com</subtitle>
	<generator>MediaWiki 1.34.2</generator>
	<entry>
		<id>http://robopagex.com/index.php?title=SQL_TUNING&amp;diff=1044&amp;oldid=prev</id>
		<title>Geist: Die Seite wurde neu angelegt: „== SQL &amp; PERFORMANCE TUNING ==  - What is SQL Tuning and why we need it?  - Oracle Database Architecture  - SQL Tuning Basics  - Execution Plans in Details  -…“</title>
		<link rel="alternate" type="text/html" href="http://robopagex.com/index.php?title=SQL_TUNING&amp;diff=1044&amp;oldid=prev"/>
		<updated>2022-06-20T09:18:33Z</updated>

		<summary type="html">&lt;p&gt;Die Seite wurde neu angelegt: „== SQL &amp;amp; PERFORMANCE TUNING ==  - What is SQL Tuning and why we need it?  - Oracle Database Architecture  - SQL Tuning Basics  - Execution Plans in Details  -…“&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Neue Seite&lt;/b&gt;&lt;/p&gt;&lt;div&gt;== SQL &amp;amp; PERFORMANCE TUNING ==&lt;br /&gt;
 - What is SQL Tuning and why we need it?&lt;br /&gt;
 - Oracle Database Architecture&lt;br /&gt;
 - SQL Tuning Basics&lt;br /&gt;
 - Execution Plans in Details&lt;br /&gt;
 - Join Operations&lt;br /&gt;
 - Basic Tuning Techniques&lt;br /&gt;
 - Advanced Indexing Techniques&lt;br /&gt;
 - Hints&lt;br /&gt;
 - Subjects&lt;br /&gt;
&lt;br /&gt;
 Change SQL-Structure or Database-Structure&lt;br /&gt;
 Need to know of the Database Architecture in Basic&lt;br /&gt;
&lt;br /&gt;
 Tools&lt;br /&gt;
 - SQL plus&lt;br /&gt;
 - SQL Developer&lt;br /&gt;
 - SQL Tuning Advisor&lt;br /&gt;
 is internal diagnostic software that identifies problematic SQL statements and recommends how to improve statement performance.&lt;br /&gt;
 - Automatic SQL Tuning Advisor&lt;br /&gt;
 - SQL Access Advisor &lt;br /&gt;
 is internal diagnostic software that recommends which materialized views, indexes, and  materialized view logs to create, drop, or retain.&lt;br /&gt;
 - Automatic Database Diagnostic Monitor (ADDM)&lt;br /&gt;
 ADDM is self-diagnostic software built into Oracle Database.&lt;br /&gt;
 - TOAD&lt;br /&gt;
 - AWR&lt;br /&gt;
 - TKPROF&lt;br /&gt;
&lt;br /&gt;
 - Determine the bottlenecks in low-performance Oracle databases&lt;br /&gt;
 - Use Oracle database performance tuning tools, like: AWR, ASH, V$ views, SQL tracing, real-time monitoring, and EM Express&lt;br /&gt;
 - Propose solutions to database performance issues&lt;br /&gt;
 - Implement Oracle methodology in performance tuning&lt;br /&gt;
&lt;br /&gt;
 SQL Tuning is a continuous process&lt;br /&gt;
 You need to tune your queris&lt;br /&gt;
 - While creating&lt;br /&gt;
 - After the creating&lt;br /&gt;
&lt;br /&gt;
 When to decide tuning?&lt;br /&gt;
 - By checking the top consuming queries frequently&lt;br /&gt;
 - After any complaints of bad performance&lt;br /&gt;
&lt;br /&gt;
 The reasons of performance loss&lt;br /&gt;
 - Structural changes&lt;br /&gt;
 - Changes on the data volume&lt;br /&gt;
 - Application changes&lt;br /&gt;
 - Aged statistics&lt;br /&gt;
 - Database upgrades&lt;br /&gt;
 - Database parameter changes&lt;br /&gt;
 - Operating system changes&lt;br /&gt;
 - hardware changes&lt;br /&gt;
&lt;br /&gt;
=== Blocks ===&lt;br /&gt;
 All data stored in blocks&lt;br /&gt;
 smallest unit of database storage&lt;br /&gt;
 2KB-32KB(default 8KB)&lt;br /&gt;
 stores row data or index data&lt;br /&gt;
&lt;br /&gt;
 Eigenschaften:&lt;br /&gt;
 - Block Header&lt;br /&gt;
   Block Type Information&lt;br /&gt;
   Table Information&lt;br /&gt;
   Row Directory&lt;br /&gt;
     ROWID(Like pointer?)&lt;br /&gt;
 - Rows&lt;br /&gt;
 Blocks in Blocks&lt;br /&gt;
 Jeder Block wird in eine bestimmte Stelle geschrieben&lt;br /&gt;
 &lt;br /&gt;
 PCTFREE or PCTUSE parameters for the space size in blocks&lt;br /&gt;
 &lt;br /&gt;
 Wenn nicht genug Platz, wird bei jedem update wahrscheinlich die Position geändert&lt;br /&gt;
 - Verringerte Leistung &lt;br /&gt;
 - IO-OPS werden langsamer&lt;br /&gt;
 - Schlecht für das Tuning&lt;br /&gt;
 - Verlangsamt die Indexes&lt;br /&gt;
&lt;br /&gt;
 Das lesen einer Zeile, von einer Tabelle aus einem Block, ist schneller als aus mehreren Blöcken&lt;br /&gt;
&lt;br /&gt;
 1. Row Header&lt;br /&gt;
 2. Column Data&lt;br /&gt;
&lt;br /&gt;
 - Row Overhead&lt;br /&gt;
 - Number of Columns&lt;br /&gt;
 - Cluster Key ID(if clustered)&lt;br /&gt;
 - ROWID of chained Row Pieces(if any)&lt;br /&gt;
 - Column Length&lt;br /&gt;
 - Column Value&lt;br /&gt;
&lt;br /&gt;
 Wenn die größe der Blocks in den Abfragen verringert wird, steigert man die Leistung&lt;br /&gt;
&lt;br /&gt;
=== PGA | PROGRAM/PROCESS/PRIVATE GLOBAL AREA ===&lt;br /&gt;
 Private for each user&lt;br /&gt;
&lt;br /&gt;
 ''4 Hauptspeicher Bereiche:''&lt;br /&gt;
 '''PGA'''&lt;br /&gt;
 Session AREA&lt;br /&gt;
    - Session info for each user&lt;br /&gt;
    - Session Variables, login info, session status, etc.&lt;br /&gt;
 Unnötige verbindungen vermeiden&lt;br /&gt;
&lt;br /&gt;
 '''PSA(Private SQL Area)'''&lt;br /&gt;
 PERSISTENT AREA&lt;br /&gt;
   - Jede Abfrage wird zu einem Cursor&lt;br /&gt;
   - Verwendete Bindvariablen der Cursor werden hier gespeichert&lt;br /&gt;
 RUNTIME AREA&lt;br /&gt;
   - Execution state info&lt;br /&gt;
 CURSOR AREA&lt;br /&gt;
 - Information of cursors&lt;br /&gt;
&lt;br /&gt;
 '''SQL WORK AREA'''&lt;br /&gt;
 SORT AREA&lt;br /&gt;
 HASH JOIN AREA&lt;br /&gt;
 BITMAP MERGE AREA&lt;br /&gt;
 BITMAP CREATE AREA&lt;br /&gt;
&lt;br /&gt;
 Weniger Speicher verringert die LEistung&lt;br /&gt;
&lt;br /&gt;
 Speichergröße festlegen&lt;br /&gt;
 - User&lt;br /&gt;
 - Oracle selber&lt;br /&gt;
&lt;br /&gt;
=== SGA | SHARED/SYSTEM GLOBAL AREA ===&lt;br /&gt;
 Database buffer cache&lt;br /&gt;
 Redo log buffer&lt;br /&gt;
 Shared pool&lt;br /&gt;
  - Data dictionary cache&lt;br /&gt;
  - Result Cache&lt;br /&gt;
  - other&lt;br /&gt;
 Large pool&lt;br /&gt;
 - I/O Buffer&lt;br /&gt;
 - Free memory&lt;br /&gt;
 - Response queue&lt;br /&gt;
 - Request queue&lt;br /&gt;
 JAVA pool&lt;br /&gt;
 Streams pool&lt;br /&gt;
&lt;br /&gt;
 Context switching between pl/sql engine and sql engine&lt;br /&gt;
&lt;br /&gt;
=== SHARED POOL ===&lt;br /&gt;
 '''DATA DICTIONARY CACHE'''&lt;br /&gt;
 - Stores the definitions of the database object and permissions&lt;br /&gt;
   - check if Data from query exists&lt;br /&gt;
   - check your privileges&lt;br /&gt;
&lt;br /&gt;
 '''RESULT CACHE'''&lt;br /&gt;
 - stores result of common used queries&lt;br /&gt;
 - stores result of functin&lt;br /&gt;
   - Bei wiederholter Abfrage wird aus dem RESULT CACHE gelesen&lt;br /&gt;
   - Speicher die Abfrageergebnisse&lt;br /&gt;
   - Speicher die Funktionsergebnisse&lt;br /&gt;
&lt;br /&gt;
 Erhöht die Leistung&lt;br /&gt;
 Wird von der Datenbank durchgeführt&lt;br /&gt;
 User kann anweisen Result Cache anweisen daten zu speichern&lt;br /&gt;
&lt;br /&gt;
 '''Library Cache'''&lt;br /&gt;
 - Stores the execution plans&lt;br /&gt;
 - Stores procedures, packages control structures&lt;br /&gt;
   Oracle erstellt Ausführungspläne&lt;br /&gt;
   Wie die Daten aus der Disc oder dem Puffer gelesen werden&lt;br /&gt;
   Die Erstellung eines Ausführungsplans ist ein kostspieliger Vorgang&lt;br /&gt;
   Die Verwendung eines Ausführungsplans für ähnliche Abfragen kann sehr effizient sein&lt;br /&gt;
&lt;br /&gt;
 '''OTHER AREAS'''&lt;br /&gt;
&lt;br /&gt;
=== BUFFER CACHE ===&lt;br /&gt;
 '''Largest memory area of sga'''&lt;br /&gt;
 Stores the copies of the blocks read from the disc&lt;br /&gt;
 Available for all the users&lt;br /&gt;
 First check Buffer than Disc, for the data&lt;br /&gt;
 Check Disc only if blocks are missing&lt;br /&gt;
 Much faster than disc&lt;br /&gt;
 Size of the memory is endless&lt;br /&gt;
 Maintained with a complex algorithm&lt;br /&gt;
 Can't save all data in buffer cache&lt;br /&gt;
 &lt;br /&gt;
 '''IN-MEMORY-DATABASES'''&lt;br /&gt;
 Stores the most recently used &amp;amp; most toched ones&lt;br /&gt;
 '''Database writer process''' handles the write operations to the disc&lt;br /&gt;
 Writes not one by one, writes all changed blocks in one step&lt;br /&gt;
 '''dirty blocks'''&lt;br /&gt;
 Stores Tabledata and Indexdata&lt;br /&gt;
&lt;br /&gt;
 Performance for same&lt;br /&gt;
 - queries&lt;br /&gt;
 - tables&lt;br /&gt;
 - indexes&lt;br /&gt;
&lt;br /&gt;
=== REDO LOG BUFFER ===&lt;br /&gt;
 '''-&amp;gt; Log Writer Process(LGWR)'''&lt;br /&gt;
 '''-&amp;gt; Redo Log Entries'''&lt;br /&gt;
 '''-&amp;gt; Redo Log Files'''&lt;br /&gt;
 '''-&amp;gt; Server Process''' &lt;br /&gt;
&lt;br /&gt;
 Redo-Log-Files&lt;br /&gt;
 Oracle Guarantees Not to Lose Data&lt;br /&gt;
 - A Redo Log Entry is created when insert, update, delete, create, alter, drop occurs&lt;br /&gt;
 Create Redo Log entries for all changes&lt;br /&gt;
 Redo Log Entries has the changes made to the database&lt;br /&gt;
 They are used for recovery operatins&lt;br /&gt;
 You need privileges as a developer&lt;br /&gt;
 Redo Log Entries are Stored in the redo log buffer&lt;br /&gt;
 Starts every 3 sec and write to disc&lt;br /&gt;
 '''Redo Log buffer is a circular buffer'''&lt;br /&gt;
 '''Rollback is not done with redo log data'''&lt;br /&gt;
 Redo do recovery on rollback redo log files are deleted&lt;br /&gt;
&lt;br /&gt;
=== UNDO ===&lt;br /&gt;
 What is rollback and recovery&lt;br /&gt;
 The original data stored into the memory(undo tablespace) is called as undo data&lt;br /&gt;
 buffer cache for the modifications&lt;br /&gt;
 undo data is not modified because&lt;br /&gt;
   - Used for rollback operations&lt;br /&gt;
   - Used for providing read consistency&lt;br /&gt;
   - Used for providing flashback feature&lt;br /&gt;
&lt;br /&gt;
 '''BLOCKS &amp;gt; EXTENTS &amp;gt; SEGMENTS &amp;gt; TABLESPACE'''&lt;br /&gt;
&lt;br /&gt;
=== DML PROCESS AND COMMIT ===&lt;br /&gt;
 Optimize Queries and DML's&lt;br /&gt;
 - Checks the Shared SQL AREA for similar statements to use&lt;br /&gt;
 - checks the data dictionary cache and checks if query is valid&lt;br /&gt;
 - Checks buffer cache &amp;amp; undo segements for the related data&lt;br /&gt;
 - Locks the related blocks&lt;br /&gt;
 - Makes the changes to the blocks in the buffer cache&lt;br /&gt;
 - the changes are applied to the redo log buffer before the buffer cache&lt;br /&gt;
 - the server returns the feedback for the changes&lt;br /&gt;
&lt;br /&gt;
 When the user commits:&lt;br /&gt;
 - System change number write to redo log files&lt;br /&gt;
 - the server creates a commitrecord with scn&lt;br /&gt;
 - the lgwr process write redo log entries in the redo log buffer to the redo log files&lt;br /&gt;
 - the dbwn writes the dirty blocks to the disc &amp;amp; unlocks the blocks&lt;br /&gt;
 - The server returns a feedback about the transaction completion&lt;br /&gt;
&lt;br /&gt;
=== Automatic memory management===&lt;br /&gt;
 The size of each memory ara is important for the execution performance of your queries&lt;br /&gt;
 Wenn des Speicherbereich nicht ausreicht verringert das die performance&lt;br /&gt;
 It can manage both SGA &amp;amp; PGA memory &lt;br /&gt;
 In früheren versionen von oracle musste PGA manuell angegeben werden&lt;br /&gt;
 '''it is recommended to leave automatic memory management enabled to increase the performance'''&lt;br /&gt;
 will prefent out of memory errors&lt;br /&gt;
&lt;br /&gt;
=== Oracle database storage architecture===&lt;br /&gt;
 - '''Storage''' = Discs&lt;br /&gt;
 - '''Control files''' storage the pyhsical structure information of the database(without no access to data)&lt;br /&gt;
 - '''Data Files''' - Stores data(Tables, procedures, application, data&lt;br /&gt;
 - '''Online Redo log files''': stores redo log entries&lt;br /&gt;
 - '''archived redo log files''' - online redo log files are constantly mover ehre&lt;br /&gt;
 - '''backup files''' - Stores the exact copy of the data files for disaster recovery&lt;br /&gt;
 - '''Parameter files''' - Stores the configuration data of the database instance&lt;br /&gt;
 - '''password file''' - Stores the passwords of the amin user(sysdba,sysoper,sysasm)&lt;br /&gt;
 - alert log &amp;amp; trace files - stores log message and errors occured in the database&lt;br /&gt;
 &lt;br /&gt;
 Some Informations are for the dev's and some for the oracle support service&lt;br /&gt;
&lt;br /&gt;
=== Logical and Physical Database structure ===&lt;br /&gt;
 - Blocks | smallest units of storage(2kb-32kb)&lt;br /&gt;
 - Extents | combination of several consecutive data blocks.&lt;br /&gt;
   used for stroing secific type of info&lt;br /&gt;
 - segments | combination of several extents&lt;br /&gt;
  used for storing some big data(tables,indexes, etc)&lt;br /&gt;
   - data segments&lt;br /&gt;
   - index segments&lt;br /&gt;
   - undo segments&lt;br /&gt;
   - temporary segments&lt;br /&gt;
 - tablespaces | combination of many segments. used for grouping the related data in one container&lt;br /&gt;
  - Temporary Tabelspace&lt;br /&gt;
    Stores teh temporary data of a session&lt;br /&gt;
  - Permanent Tablespace&lt;br /&gt;
    Stores the persistent schema objects&lt;br /&gt;
&lt;br /&gt;
 '''DB must have min 2 Tablespaces'''&lt;br /&gt;
 - System Tablespace&lt;br /&gt;
 - SYSAUX Tablespace&lt;br /&gt;
 DBA can create more Tablespaces&lt;br /&gt;
&lt;br /&gt;
 Check for Performance&lt;br /&gt;
 Set Tablespaces Online and Offline Status&lt;br /&gt;
 Can do backup or recovery of a give tablespace&lt;br /&gt;
 Import or export Tablespaces&lt;br /&gt;
 Create a transportable tablespace and move too other db&lt;br /&gt;
&lt;br /&gt;
=== Schema ===&lt;br /&gt;
 Ein Schema ist eine Sammlung von Datenbankobjekten die einem Datenbankbenutzer gehören&lt;br /&gt;
&lt;br /&gt;
=== PERFORMANCE TUNING BASICS ===&lt;br /&gt;
 SQL Tuning is a continuous process&lt;br /&gt;
 You nedd to tune your queries&lt;br /&gt;
  - on creating&lt;br /&gt;
  - After the creation&lt;br /&gt;
  - On new Indexes created&lt;br /&gt;
  - Change of data volume&lt;br /&gt;
 &lt;br /&gt;
 When to decide tuning?&lt;br /&gt;
  - checking the top consuming queries frequently&lt;br /&gt;
  - after any complaints of bad performance&lt;br /&gt;
 &lt;br /&gt;
 two goals in tuning:&lt;br /&gt;
 - reduce user response time, decreasing time between statement and response&lt;br /&gt;
 - Improve throughput&lt;br /&gt;
 &lt;br /&gt;
 Knowledge and skills:&lt;br /&gt;
 - know your db architecture&lt;br /&gt;
 - sql&lt;br /&gt;
 - sql tuning tools&lt;br /&gt;
&lt;br /&gt;
 Check oracle database statistics&lt;br /&gt;
 &lt;br /&gt;
 Betriebssystem&lt;br /&gt;
 - Software&lt;br /&gt;
 - Services&lt;br /&gt;
 - Updates&lt;br /&gt;
 - Datenbank, Oracle Datenbank Architektur&lt;br /&gt;
 &lt;br /&gt;
 Häufige Ursache für Performance Verlust, bei Änderung von:&lt;br /&gt;
 - Tabellen, DB Struktur&lt;br /&gt;
 - Datenvolumen&lt;br /&gt;
 - Applikationen&lt;br /&gt;
 - Datenbank-Update&lt;br /&gt;
 - Datenbank-Parameter&lt;br /&gt;
 - Betriebssystem&lt;br /&gt;
 - Betriebssystem-Update&lt;br /&gt;
 - Betriebssystem-Konfiguration&lt;br /&gt;
 - Hardware&lt;br /&gt;
&lt;br /&gt;
 Welche Oracle Packages für:&lt;br /&gt;
 - Modularity&lt;br /&gt;
 - Easy Maintenance&lt;br /&gt;
 - Encapsulation &amp;amp; Security&lt;br /&gt;
 - Performance&lt;br /&gt;
 - Functionality&lt;br /&gt;
 - Overloading&lt;br /&gt;
&lt;br /&gt;
 Tuning-Maßnahmen | SQL &amp;amp; PERFORMANCE TUNING&lt;br /&gt;
 - SQL Tuning Basics&lt;br /&gt;
 - Execution Plans in Details&lt;br /&gt;
 - Join Operations&lt;br /&gt;
 - Basic Tuning Techniques&lt;br /&gt;
 - Advanced Indexing Techniques&lt;br /&gt;
 - Hints&lt;br /&gt;
 - Subjects&lt;br /&gt;
&lt;br /&gt;
=== BAD SQL ===&lt;br /&gt;
 Unnecessary:&lt;br /&gt;
 - parse time&lt;br /&gt;
 - I/O operations&lt;br /&gt;
 - CPU Time&lt;br /&gt;
 - waits&lt;br /&gt;
&lt;br /&gt;
 '''TIME on Wait(CPU) + Time on Execution = DB TIME'''&lt;br /&gt;
 The reason of a bad sql&lt;br /&gt;
 - bad design&lt;br /&gt;
 - poor coding&lt;br /&gt;
 - inefficient execution plan&lt;br /&gt;
&lt;br /&gt;
=== Effective Schema Design ===&lt;br /&gt;
 - Assign data types as much as needed&lt;br /&gt;
 - datatypes with variable-length&lt;br /&gt;
 - check data-consistency problems&lt;br /&gt;
 - select exactly the same data type between parent-child-keys&lt;br /&gt;
 - don't use varchar2 for the most of the datatypes/strings/values&lt;br /&gt;
&lt;br /&gt;
 Enforce data integrity&lt;br /&gt;
 - correct PK and FK&lt;br /&gt;
 - use normalization well&lt;br /&gt;
 - smaller tables, faster join operation&lt;br /&gt;
 - select right table type&lt;br /&gt;
   - heap-organized table&lt;br /&gt;
   - Index Clustered tables&lt;br /&gt;
   - Hash Clustered tables&lt;br /&gt;
   - Index-Organized tables&lt;br /&gt;
   - External tables&lt;br /&gt;
   - and more&lt;br /&gt;
 - Create Clusters&lt;br /&gt;
 - use indexes often and select index type carefully&lt;br /&gt;
 - create good indexes methods&lt;br /&gt;
 - Create index-organized tables(IOT)&lt;br /&gt;
&lt;br /&gt;
=== table partitioning ===&lt;br /&gt;
&lt;br /&gt;
=== SQL STATEMENT PROCESSED ===&lt;br /&gt;
 -&amp;gt; '''Syntax check'''&lt;br /&gt;
 -&amp;gt; '''Semantic check'''&lt;br /&gt;
 -&amp;gt; '''Privilege check'''&lt;br /&gt;
 -&amp;gt; '''Allocate private SQL AREA'''&lt;br /&gt;
 Existing shared SQL AREA&lt;br /&gt;
 NO-&amp;gt; '''HARDPARSE'''(Library cache miss)&lt;br /&gt;
  -&amp;gt; Allocate shared sql area&lt;br /&gt;
  -&amp;gt; optimization&lt;br /&gt;
  -&amp;gt; row source generation&lt;br /&gt;
 YES-&amp;gt; '''SOFTPARSE'''&lt;br /&gt;
 -&amp;gt; EXECUTE STATEMENT&lt;br /&gt;
&lt;br /&gt;
 Softparse is faster, use for tuning&lt;br /&gt;
 - Hashwert in Libcache&lt;br /&gt;
  - Key for the executionplan in shared sql area&lt;br /&gt;
 - executionplan is stored in shared library&lt;br /&gt;
&lt;br /&gt;
 Optimierer ist Software die Abfrage als Eingabe erhält und den besten ExecutionPlan erstellt&lt;br /&gt;
&lt;br /&gt;
 Full-table scan&lt;br /&gt;
 Index scan&lt;br /&gt;
&lt;br /&gt;
 '''1. Optimization'''&lt;br /&gt;
 '''2. Execution plans'''&lt;br /&gt;
 '''3. Row Source Generation'''&lt;br /&gt;
&lt;br /&gt;
 Result-Cache&lt;br /&gt;
&lt;br /&gt;
 Select * from... STEPS&lt;br /&gt;
 -&amp;gt; Check Schema Information&lt;br /&gt;
 -&amp;gt; Find possible access paths&lt;br /&gt;
   -&amp;gt; Use Index&lt;br /&gt;
   -&amp;gt; Read whole table&lt;br /&gt;
 -&amp;gt; check statistics&lt;br /&gt;
&lt;br /&gt;
 selective query&lt;br /&gt;
 &lt;br /&gt;
 '''Don't use Index if Result is bigger than 25% of the whole table?'''&lt;br /&gt;
&lt;br /&gt;
==== Access Methods====&lt;br /&gt;
 - Table Access Path&lt;br /&gt;
   - Full-Table scan&lt;br /&gt;
   - Table Access by ROWID&lt;br /&gt;
 - B-Tree Indexx Access Path&lt;br /&gt;
   - Index unique scan&lt;br /&gt;
   - Index range scan&lt;br /&gt;
   - Index skip scan&lt;br /&gt;
   - Full Index scan&lt;br /&gt;
 - Bitmap index Access Path&lt;br /&gt;
 - Table Cluster Access Path&lt;br /&gt;
&lt;br /&gt;
 In-List- Iterator&lt;br /&gt;
&lt;br /&gt;
=== Optimizer overview===&lt;br /&gt;
 - Optimizer&lt;br /&gt;
 - RBO | RuleBasedO(not in use anymore since 10g)&lt;br /&gt;
 - CBO | CostBaseO&lt;br /&gt;
   Plan is dynamic&lt;br /&gt;
 -&amp;gt; Query Transformer(Transform Query)&lt;br /&gt;
 -&amp;gt; Estimator(Query+estimates)&lt;br /&gt;
 ^-&amp;gt; Plan Generator(Query plan to row source generation)&lt;br /&gt;
&lt;br /&gt;
===Query Transformer===&lt;br /&gt;
 Query transforms the query into a better performing one but semantically equivalent of it&lt;br /&gt;
 If the transform isn't better, it use the original one&lt;br /&gt;
 Time restriction and old statistics may lead a wrong plan creation&lt;br /&gt;
 Or Expansion&lt;br /&gt;
  Using or in the where clause will prevent index usage&lt;br /&gt;
  &lt;br /&gt;
 '''SELECT * FROM ID WHERE ID = 1 OR ID = 2;'''&lt;br /&gt;
 Faster:&lt;br /&gt;
 '''SELECT * FROM ID WHERE ID = 1;'''&lt;br /&gt;
 '''UNION ALL'''&lt;br /&gt;
 '''SELECT * FROM ID WHERE ID = 2;'''&lt;br /&gt;
&lt;br /&gt;
 Subquery Unnesting&lt;br /&gt;
 Verschachtelte Abfrage in Join-Anweisung&lt;br /&gt;
 '''SELECT * FROM ID WHERE ID IN'''&lt;br /&gt;
    '''(SELECT ID FROM CLIENTS)'''&lt;br /&gt;
 The otimizer transfomrs a nested query into a join statement&lt;br /&gt;
 SELECT ID,*&lt;br /&gt;
 FROM ID, CLIENTS&lt;br /&gt;
 WHERE ID.ID = CLIENTS.ID;&lt;br /&gt;
&lt;br /&gt;
 Complex VIEW&lt;br /&gt;
&lt;br /&gt;
=== Selectivity &amp;amp; Cardinality ===&lt;br /&gt;
 Selectivity = NUMBER OF ROWS FROM QUERY / TOTAL NUMBERS OF THE ROWS&lt;br /&gt;
 Cardinality = Total numbers of rows x Selectivity&lt;br /&gt;
 &lt;br /&gt;
 Why selectivity and cardinality is important?&lt;br /&gt;
 - SEL affects the estimates in I/O cost&lt;br /&gt;
 - SEL affects the sort cost&lt;br /&gt;
 - CAR is used to determine join, sort and filter costs&lt;br /&gt;
 - Incorrect SEL and CAR = incorrect plan cost estimation&lt;br /&gt;
&lt;br /&gt;
=== COST IN DETAIL ===&lt;br /&gt;
 - Cost is the optimizer's best estimate of the numbers of I/O to execute statement&lt;br /&gt;
 - To estimate the cost, the estimator uses:&lt;br /&gt;
  - Disk I/O&lt;br /&gt;
  - CPU usage&lt;br /&gt;
  - Memory usage&lt;br /&gt;
&lt;br /&gt;
 '''COST = SINGLE-BLOCK I/O COST + MULTI-BLOCK I/O COST + CPU COST / SINGLE-BLOCK READ TIME'''&lt;br /&gt;
 - SINGEL BLOCK READ TIME&lt;br /&gt;
 - MULTI BLOCK READ TIME&lt;br /&gt;
 - CPU CYCLES / CPU SPEED&lt;br /&gt;
&lt;br /&gt;
=== PLAN GENERATOR ===&lt;br /&gt;
 Basierend auf ausprobieren von verschiedenen Zugriffspfaden,JOIN-Methoden und JOIN-Reihenfolgen&lt;br /&gt;
&lt;br /&gt;
=== ROW SOURCE GENERATOR===&lt;br /&gt;
 once the plan generator generates the optimum plan, it handles that to the row source generator&lt;br /&gt;
 generates an interative execution plan usabel for the database&lt;br /&gt;
 is an area that we get the row set(Table,view,result of join or groups)&lt;br /&gt;
 row source tree show the following information:&lt;br /&gt;
 - execution order&lt;br /&gt;
 - access methods&lt;br /&gt;
 - join methods&lt;br /&gt;
 - data operatons(filter,sort,...)&lt;br /&gt;
&lt;br /&gt;
=== SQL TUNING PRINICPLES AND STRATEGIES===&lt;br /&gt;
 SQL TUNING PRINCIPALS&lt;br /&gt;
 - IDENTIFYING the issue&lt;br /&gt;
 - carify teh details of that issue&lt;br /&gt;
 - collection data&lt;br /&gt;
 - analyze the data&lt;br /&gt;
 - choose an appropriate tuning strategy&lt;br /&gt;
 &lt;br /&gt;
 SQL TUNING STRATEGIES&lt;br /&gt;
 - Parse time reduction&lt;br /&gt;
 - plan comparison strategy&lt;br /&gt;
 - quick solution strategy&lt;br /&gt;
 - finding &amp;amp; implementing a good plan&lt;br /&gt;
 - '''Query analysis strategy'''&lt;br /&gt;
&lt;br /&gt;
 SQL TUNING ADVISOR(braucht zugriffsrechte)&lt;br /&gt;
 otimierungsmodus ändern&lt;br /&gt;
 index-caching&lt;br /&gt;
 etc..&lt;br /&gt;
 &lt;br /&gt;
 Use dynamic stats to create better plans&lt;br /&gt;
&lt;br /&gt;
=== QUERY ANALYSIS STRATEGIE===&lt;br /&gt;
 - quick tuning strategies did not work, and we have time to work on this problem&lt;br /&gt;
 - query can be modified&lt;br /&gt;
 - determine the underlying cause&lt;br /&gt;
 &lt;br /&gt;
 '''What to do on this strategy'''&lt;br /&gt;
 - statistics and parameters&lt;br /&gt;
 - query structure&lt;br /&gt;
 - access paths&lt;br /&gt;
 - join orders &amp;amp; join methods(changes?)&lt;br /&gt;
 - others&lt;br /&gt;
&lt;br /&gt;
 '''Collecting Data'''&lt;br /&gt;
 - Execution plan&lt;br /&gt;
 - information of the objects in the query&lt;br /&gt;
 - collecting statistics&lt;br /&gt;
   - object stats&lt;br /&gt;
   - systems stats&lt;br /&gt;
 - histograms&lt;br /&gt;
 '''The available tools are'''&lt;br /&gt;
 - sqlt&lt;br /&gt;
 - dbms_stats&lt;br /&gt;
 - tkprof&lt;br /&gt;
 - awr report&lt;br /&gt;
 - etc..&lt;br /&gt;
&lt;br /&gt;
 '''Systemstatistiken und Histogramme'''&lt;br /&gt;
&lt;br /&gt;
 '''PRE-ANALYZE of the Query'''&lt;br /&gt;
 - check the&lt;br /&gt;
   - volumes of resulting data&lt;br /&gt;
   - predicates&lt;br /&gt;
   - problematic constructs&lt;br /&gt;
     - OUTER JOIN&lt;br /&gt;
     - VIEWS&lt;br /&gt;
     - SUBQUERIES&lt;br /&gt;
     - IN or OR list&lt;br /&gt;
     - Hierarchical queries&lt;br /&gt;
&lt;br /&gt;
 '''Analyzing the execution plan'''&lt;br /&gt;
 '''Tools to get the execution plan'''&lt;br /&gt;
   - SQL TRACE&lt;br /&gt;
   - TKPROF&lt;br /&gt;
   - V$_SQL_PLAN&lt;br /&gt;
   - DBMS_MONITOR&lt;br /&gt;
   - AWRSQRPT.SQL&lt;br /&gt;
   - etc..&lt;br /&gt;
&lt;br /&gt;
 '''How to read the execution plan:'''&lt;br /&gt;
 - check the access paths&lt;br /&gt;
 - check the join order and the join type&lt;br /&gt;
 - compare actual &amp;amp; estimated number of rows&lt;br /&gt;
 - find the steps where cost and logical reads are different&lt;br /&gt;
&lt;br /&gt;
 '''Analyzing by considering the query tuning techniques'''&lt;br /&gt;
 &lt;br /&gt;
 '''Find a possible solution'''&lt;br /&gt;
 - updating statitics&lt;br /&gt;
 - using dynamic stats&lt;br /&gt;
 - creating or re-create an index&lt;br /&gt;
 - creating index-organized tables(IOT)&lt;br /&gt;
 - using hints&lt;br /&gt;
 - others&lt;br /&gt;
&lt;br /&gt;
=== EXECUTION PLAN AND EXPLAIN IN DETAIL===&lt;br /&gt;
 An execution plan is a list of steps how to execute an sql statement&lt;br /&gt;
&lt;br /&gt;
 - Operations&lt;br /&gt;
 - Object_name&lt;br /&gt;
 - Cardinality&lt;br /&gt;
 - Cost&lt;br /&gt;
 - Partition_Start&lt;br /&gt;
 - Partition_Stop&lt;br /&gt;
&lt;br /&gt;
 Stat types&lt;br /&gt;
 - system stats&lt;br /&gt;
 - optimizer stats&lt;br /&gt;
 System stats&lt;br /&gt;
  - used by the optimizer to estimate I/O and CPU&lt;br /&gt;
  - costs&lt;br /&gt;
  - should be generated regularly&lt;br /&gt;
 - shoud be gathered during a normal workload&lt;br /&gt;
&lt;br /&gt;
 regenaration/recreate on every hardware change the system stats&lt;br /&gt;
 &lt;br /&gt;
 Access Predicates&lt;br /&gt;
 Filter Preddiactes&lt;br /&gt;
 &lt;br /&gt;
 USE OF:&lt;br /&gt;
 '''EXEC dbms_stats.gather_system_stats('Start');'''&lt;br /&gt;
 Prozedur&lt;br /&gt;
 collect_system_stats()&lt;br /&gt;
&lt;br /&gt;
 Berechtigung auf Tabelle '''aux_stats$'''&lt;br /&gt;
&lt;br /&gt;
 Optimizer Statitics&lt;br /&gt;
 - can be gathered manually or autmatically&lt;br /&gt;
 &lt;br /&gt;
 Dynamic stats?&lt;br /&gt;
&lt;br /&gt;
 Job für Automatische Erfassung der Statistiken&lt;br /&gt;
&lt;br /&gt;
 ANALYZE TABLE [TABLE_NAME] COMPUTE STATISTICS;&lt;br /&gt;
 Sollte nicht mehr genutzt werden&lt;br /&gt;
 &lt;br /&gt;
 DBMS_STATS package&lt;br /&gt;
 PROCEDURES:&lt;br /&gt;
 GATHER_DATABASE_STATS &lt;br /&gt;
 GATHER_DICTIONARY_STATS&lt;br /&gt;
 GATHER_SCHEMA_STATS&lt;br /&gt;
 GATHER_TABLE_STATS | very fast&lt;br /&gt;
 GATHER_INDEX_STATS | faster for singel indexes&lt;br /&gt;
&lt;br /&gt;
 How can see the optimizer statistics&lt;br /&gt;
 - DBA_TABLES&lt;br /&gt;
 - DBA_TAB_STATISTICS&lt;br /&gt;
 - DBA_COL_STATISTICS&lt;br /&gt;
 - DBA_INDEXES&lt;br /&gt;
 - DBA_CLUSTERS&lt;br /&gt;
 - DBA_TAB_PARTITIONS&lt;br /&gt;
 - DBA_IND_PARTITIONS&lt;br /&gt;
 - DBA_PART_COL_STATISTICS&lt;br /&gt;
&lt;br /&gt;
=== Generating Execution plan ===&lt;br /&gt;
 To analyze an execution plan&lt;br /&gt;
   - explain plan&lt;br /&gt;
   - autotrace&lt;br /&gt;
   - V$SQL_PLAN&lt;br /&gt;
 EXPLAIN PLAN&lt;br /&gt;
 '''EXPLAN PLAN FOR [QUERY];'''&lt;br /&gt;
 generates the explain plan and save into plan_table&lt;br /&gt;
 &lt;br /&gt;
 select * from plan_table;&lt;br /&gt;
&lt;br /&gt;
=== AUTOTRACE ===&lt;br /&gt;
 SET AUTOTRACE ON;&lt;br /&gt;
 SET AUTOTRACE ON [EXPLAIN|STATISTICS];&lt;br /&gt;
 SET AUTOTRACE TRACE[ONLY] ON [EXPLAIN|STATISTICS];&lt;br /&gt;
 SET AUTOTRACE OFF;&lt;br /&gt;
&lt;br /&gt;
 Autotrace uses plan table like the explain plan&lt;br /&gt;
 Bindvariablen mit implizierter typenkonvertierung, klappt manchmal nicht&lt;br /&gt;
&lt;br /&gt;
 SQLPLUS&amp;gt;&amp;gt; &lt;br /&gt;
 SQL&amp;gt; set linesize 200;&lt;br /&gt;
 SQL&amp;gt; set autotrace traceonly explain;&lt;br /&gt;
 SQL&amp;gt; select * from sales s, customers c where s.cust_id = c.cust_id and s.cust_id = 987;&lt;br /&gt;
 SQL&amp;gt; set autotrace traceonly statistics;&lt;br /&gt;
 SQL&amp;gt; set autotrace traceonly statistics;&lt;br /&gt;
 SQL&amp;gt; set autotrace traceonly;&lt;br /&gt;
 SQL&amp;gt; set autotrace on;&lt;br /&gt;
 SQL&amp;gt; show autotrace;&lt;br /&gt;
&lt;br /&gt;
 AUTOTRACE WITH SQL DEVELOPER&lt;br /&gt;
&lt;br /&gt;
 Kann man den Code nicht durch generieren des explain-plans optimieren, nutzt man autotrace-methoden&lt;br /&gt;
 Bei DML-OPS zuerst den EXPLAIN-PLAN&lt;br /&gt;
&lt;br /&gt;
=== V$SQL_PLAN VIEW ===&lt;br /&gt;
 There are a lot of performance views tha can be used for tuning&lt;br /&gt;
 - V$SQLAREA&lt;br /&gt;
 - V$SQL_WORKAREA&lt;br /&gt;
 - V$SQL&lt;br /&gt;
 - V$SQL_PLAN&lt;br /&gt;
 - V$SQL_PLAN_STATISTICS&lt;br /&gt;
 - V$SQL_PLAN_STATISTICS_ALL&lt;br /&gt;
&lt;br /&gt;
 V$SQL_PLAN&lt;br /&gt;
 - Actaul execution plans are stored here&lt;br /&gt;
 - It is very similar to plan_table&lt;br /&gt;
 Wenn es eine Unterschied zwischen beiden gibt, gilt der Wert von V$SQL_PLAN als wahr&lt;br /&gt;
 - V$SQL view&lt;br /&gt;
 Sie können beide die Tabellenfunktin und das dbms_xplan Paket aufrufen für eine gute Ausgabe&lt;br /&gt;
&lt;br /&gt;
 '''SELECT * FROM TABLE(DBMS_XPLAN.DISPLAY_CURSOR('XXXXX'));'''&lt;br /&gt;
&lt;br /&gt;
=== READING THE EXECUTION PLANS ===&lt;br /&gt;
 Zugriffsprädikate werden für die Zeilenquellen verwendet&lt;br /&gt;
 Bitmap-KOnvertierung in ROWIDS die ROWIDS aus der eingehenden Quelle&lt;br /&gt;
 Tabellen Zugrif durch lokale Index-ROWID&lt;br /&gt;
 Oft werden 0 Costs angezeigt, welche aber nicht 0 sind sondern einfach nur zu gering&lt;br /&gt;
 &lt;br /&gt;
 2 Arten von Optimierung&lt;br /&gt;
 - kostenbasierte | '''COST-BASED-OPTIMIZATION''' (Empfehlung von Oracle)&lt;br /&gt;
 - regelbasierte  | '''RULE-BASED-OPTIMIZATION''' (Alte Art, nicht so genau)&lt;br /&gt;
&lt;br /&gt;
 ALL_ROWS&lt;br /&gt;
 ANALYZED&lt;br /&gt;
&lt;br /&gt;
 first_rows &amp;amp; .... und später den rest, schnellere Reaktionszeit&lt;br /&gt;
&lt;br /&gt;
 Parameter type 	String&lt;br /&gt;
 Syntax 	OPTIMIZER_MODE =&lt;br /&gt;
&lt;br /&gt;
 { first_rows_[1 | 10 | 100 | 1000] | first_rows | all_rows }&lt;br /&gt;
 Default value 	all_rows&lt;br /&gt;
 Modifiable 	ALTER SESSION, ALTER SYSTEM&lt;br /&gt;
&lt;br /&gt;
 [https://docs.oracle.com/cd/B19306_01/server.102/b14237/initparams145.htm#REFRN10145 OPTIMIZER_MODE]&lt;br /&gt;
&lt;br /&gt;
 Detailierte Tuning Strategie vs schnelle Tuning Strategie&lt;br /&gt;
&lt;br /&gt;
 Where to look?&lt;br /&gt;
 - Cost&lt;br /&gt;
 - Access Methods&lt;br /&gt;
 - Cardinality&lt;br /&gt;
 - JOIN Methods &amp;amp; JOIN TYPES&lt;br /&gt;
 - Partition Pruning&lt;br /&gt;
 - Others&lt;br /&gt;
 ##??&lt;br /&gt;
 - Parse count&lt;br /&gt;
 - Number of fetches&lt;br /&gt;
 - etc..&lt;br /&gt;
&lt;br /&gt;
=== Optimizer hints ===&lt;br /&gt;
 - To command the optimizer, we use optimizer hints&lt;br /&gt;
 - optimizer hints force the optimizer to pick a specific action&lt;br /&gt;
 - The optimizer may not follow your hints&lt;br /&gt;
 - If hint is not reasonable, the optimizer will ignore it&lt;br /&gt;
 - Hints can be operating on a single hash, multi-tables, a query block, a specific statement&lt;br /&gt;
&lt;br /&gt;
 Categories of the hints:&lt;br /&gt;
 - Hints for optimization approaches&lt;br /&gt;
 - Access paths hints&lt;br /&gt;
 - Query Transformation Hints&lt;br /&gt;
 - Join order Hints&lt;br /&gt;
 - Parallel Execution hint&lt;br /&gt;
 - Others..&lt;br /&gt;
&lt;br /&gt;
 SELECT /*+ hint_name(para1 para2 para3) */ id from db;&lt;br /&gt;
 - hints can used after a select, update or delete keywords&lt;br /&gt;
 - you can use the table name or its alias as the hint parameter. but if there is an alias, you cannot use the table name&lt;br /&gt;
 - There can be only one hint area&lt;br /&gt;
 - be careful on the hints you selected, especially if you are using multiple hints&lt;br /&gt;
   you may lead the optimizer to a bad execution plan&lt;br /&gt;
&lt;br /&gt;
=== Gathering stats ===&lt;br /&gt;
 optimizer statistics are crucialto sql tuning&lt;br /&gt;
&lt;br /&gt;
=== Search for * in execution plan ===&lt;br /&gt;
 - cardinality&lt;br /&gt;
 - Access method&lt;br /&gt;
 - Join method&lt;br /&gt;
 - Join type&lt;br /&gt;
 - join order&lt;br /&gt;
 - Partition pruning&lt;br /&gt;
 - parallel execution&lt;/div&gt;</summary>
		<author><name>Geist</name></author>
		
	</entry>
</feed>