Performance and Tuning - SQL query
Performance and Tuning
Below are few steps to use for performance and tuning of long running queries in Oracle database.
- Identification --> Use any tool such as Profiler, Execution Plan, AWR report
- Analysis --> Analyze the data volume of tables being used in query
- Create an Index, Only If required**
- Update table's statistics
- Rebuilding table, indexes etc.
1] Query Execution Plan
- It list out all details of how the RDBMS plan on query processing
- How the indexes will be used
- How joins will be performed
- Estimate cost
- it will tell optimizer to perform certain action
- Index hint is special syntax that you can put in SQL query
- Order of table name (Choose selective table first which having where condition)
2] Analyze Plan
- Driving table
- Join order
- Join methods
- Loops --> Nested, Hash join, Merge sort
- Full table scan
- Indexes are present but not used properly
Flow of query execution:
- Query checked for semantics
- Parsing
- Parsing can be Hard or Soft parse
- Oracle check, if the parsed statement exist in library cache
- If exist, the statement is used, otherwise it will be hard parsed & placed in library cache
- Optimizer then decides on best execution plan and execute the statement
- The data to be retrieved is fetched from buffer cache if already exist, if not then data blocks are read data fetched and stored in buffer cache & finally present the values to session based on requesting data
Comments
Post a Comment