SlideShare una empresa de Scribd logo
1 de 30
Performance Tuning
Tuning: overview
•
•
•
•
•
•
•
•
•
•
•
•

Rewrite SQL (Leccotech)
Create Index
Redefine Main memory structures (SGA in Oracle)
Change the Block Size
Materialized Views, Denormalization
Export/Import (drop indexes): defragment
Check Locks
Separate data by category in proper tablespaces
Partition Database
Redundant Arrays of Inexpensive Disks (RAID)
Redefining Client-Server Architecture
Buy Hardware
When to Index

• Large tables A field that you query by
frequently
• Field with high cardinality (not sex where
card. Is only 2)
• Smaller Fields and Fixed length are preferred.
(Obs:Most DBMSs automatically index PK)
Different Type of Indexes

•
•
•
•
•

B-Trees (traditional) indexes
Hash-cluster
Bitmap indexes
Index-Organized Tables
Reverse-Key Indexes
Create Index command

• Create index <iName> on
<tname> (<col_name>);
• Create index cidx on orders (cid);
Why do we create an index ?
(OLTP x Data Warehouse)

• A) To speed up query (SELECT) ?
• B) To speed up data entry (insert/update/delete) ?
• C) All of the above ?
Indexes (Defaults)

• Anytime a PK is created, an index is
automatically created.
• Anytime when the type of index is not
specificied, the type of index created is
a B-Trees.
B-Tree (Balanced Tree)

• Most popular type of index structure for any
programming language or database.
• When you don’t know what to do, the best
option is usually a B-Tree. They are flexible
and perform well (not very well) in several
scenarios.
• It is really the B+ tree or B* tree
B-Trees (continued)

• One node corresponds to one block/page
(minimum disk I-O).
• Non-Leaf nodes(n keys, n+1 pointers)
• Leaf-Nodes (contain n entries, where each
entry has an index and a pointer to a data
block). Also, each node has a pointer to
next node.
• All leaves are at the same height.
Good Indexing (B-Tree) Candidates

• Table must be reasonably large
• Field is queried by frequently
• Field has a high cardinality (don’t index by
sex, where the cardinality is 2!!).
• Badly balanced trees may inhibit performance.
Destroying and re-creating index may improve
performance.
Bitmap Index
• Bitmap indexes contain the key value and a
bitmap listing the value of 0 or 1 (yes/no) for
each row indicating whether the row contains
that value or not.
• May be a good option for indexing fields that
have low cardinality (opposite of B-trees).
Bitmap Index (cont.)
• Syntax: Create Bitmap index ….
• Bitmap index works better with equality tests = or in
(not with < or > )
• Bitmap index maintenance can be expensive; an
individual bit may not be locked; a single update
locks a large portion of index.
• Bitmap indexes are best in read-only datawarehouse
situations
Hash Indexing
• B-trees and Bitmap index keys are used to
find rows requiring I/O to process index
• Hash gets rows with a key based algorithm
• Rows are stored based on a hashed value
• Index size should be known at index
creation
• Example:
– create index cidx on orders (cid) hashed;
Hash Index work best with

•
•
•
•

Very-high cardinality columns
Only equal (=) tests are used
Index values do not change
Number of rows are known ahead of time
Index-Organized Tables

• Table data is incorporated into the B-Tree
using the PK as the index.
• Table data is always in order of PK. Many
sorts can be avoided.
• Index works best when there are few (and
small) columns in your table other than the
PK.
Reverse Key Indexes
• Key ‘1234’ becomes ‘4321’, etc.
• Only efficient for few scenarios involving
parallel processing and a huge amount of data.
• By reversing key values, index blocks might
be more evenly distributed reducing the
likelihood of densely or sparsely populated
indexes.
Conclusions on Indexes
• For high-cardinality key values, B-Tree
indexes are usually best.
• B-Trees work with all types of comparisons
and gracefully shrink and grow as table
changes.
• For low cardinality read-only environments,
Bitmaps may be a good option.
Query Optimizer
• A query optimizer parsers your SQL/Query
into a sequence of relational algebra
operations, determining an execution plan.
• The query optimizer figures out the best
execution plan based on rules of thumb and
information provided in the Data Dictionary
(System catalog).
Oracle Query Optimizer
• Up to version 6, Oracle Used a Rule Based
Optimizer. After version 6, Oracle offered the
Cost Based and the Rule Based Optimizer. The
default is now the Cost Based Optimizer.
Query Optimizer
• To view how the query plan you must use
either set autotrace on or explain plan. Set
autotrace on is much simpler. Explain plan is a
little bit more efficient, but more complicated.
Typical SQL operations
(results of autotrace)

•
•
•
•
•

TABLE ACCESS FULL
TABLE ACCESS BY ROWID
INDEX RANGE SCAN
INDEX UNIQUE SCAN
NESTED LOOPS
• TABLE ACCESS FULL (full table scan):
Oracle will look at every row in the table to
find the requested information. This is
usually the slowest way to access a table.
TABLE ACCESS BY ROWID
Oracle will use the ROWID method
to find a row in the table.
ROWID is a special column detailing
an exact Oracle block where
the row can be found. This is the
fastest way to access a table (faster
than any index. Less flexible than any
index).
INDEX RANGE SCAN
Oracle will search an index for a
range of values. Usually, this even
occurs when a range or between
operation is specified by the query or
when only the leading columns in a
composite index are specified by the
where clause. Can perform well or
poorly, based on the size of the range
and the fragmentation of the index.).
INDEX UNIQUE SCAN
Oracle will perform this operation
when the table’s primary key or
a unique key is part of the where
clause. This is the most efficient
way to search an index.
NESTED LOOPS
Indicates that a join operation is occurring.
Can perform well or poorly, depending on
performance on the index and table
operations of the individual tables being
joined.
Tuning SQL and PL/SQL Queries
Sometimes, Same Query written more than
1000 ways.
Generating more than 100 execution plans.
Some firms have products that re-write correctly
written SQL queries automatically.
Select emp_sal from emp where emp_id exists
(select emp_id from dept where deptname
like’mca’);
ROWID
• SELECT ROWID, …
INTO :EMP_ROWID, …
FROM EMP
WHERE EMP.EMP_NO = 56722
FOR UPDATE;
UPDATE EMP SET EMP.NAME = …
WHERE ROWID = :EMP_ROWID;
ROWID (cont.)
• Fastest
• Less Flexible
• Are very useful for removing duplicates of
rows
SELECT STATEMENT
•
•
•
•
•
•

Not exists in place of NOT IN
Joins in place of Exists
Avoid sub-selects
Exists in place of distinct
UNION in place of OR on an index column
WHERE instead of ORDER BY

Más contenido relacionado

La actualidad más candente

Useful PL/SQL Supplied Packages
Useful PL/SQL Supplied PackagesUseful PL/SQL Supplied Packages
Useful PL/SQL Supplied PackagesMaria Colgan
 
Myth busters - performance tuning 102 2008
Myth busters - performance tuning 102 2008Myth busters - performance tuning 102 2008
Myth busters - performance tuning 102 2008paulguerin
 
Goldilocks and the Three MySQL Queries
Goldilocks and the Three MySQL QueriesGoldilocks and the Three MySQL Queries
Goldilocks and the Three MySQL QueriesDave Stokes
 
B+Tree Indexes and InnoDB
B+Tree Indexes and InnoDBB+Tree Indexes and InnoDB
B+Tree Indexes and InnoDBOvais Tariq
 
Columnstore indexes in sql server 2014
Columnstore indexes in sql server 2014Columnstore indexes in sql server 2014
Columnstore indexes in sql server 2014Antonios Chatzipavlis
 
How to Analyze and Tune MySQL Queries for Better Performance
How to Analyze and Tune MySQL Queries for Better PerformanceHow to Analyze and Tune MySQL Queries for Better Performance
How to Analyze and Tune MySQL Queries for Better Performanceoysteing
 
U-SQL Does SQL (SQLBits 2016)
U-SQL Does SQL (SQLBits 2016)U-SQL Does SQL (SQLBits 2016)
U-SQL Does SQL (SQLBits 2016)Michael Rys
 
Query Optimization in SQL Server
Query Optimization in SQL ServerQuery Optimization in SQL Server
Query Optimization in SQL ServerRajesh Gunasundaram
 
SQL Pass Summit Presentations from Datavail - Optimize SQL Server: Query Tuni...
SQL Pass Summit Presentations from Datavail - Optimize SQL Server: Query Tuni...SQL Pass Summit Presentations from Datavail - Optimize SQL Server: Query Tuni...
SQL Pass Summit Presentations from Datavail - Optimize SQL Server: Query Tuni...Datavail
 
Introduction to Azure Data Lake and U-SQL for SQL users (SQL Saturday 635)
Introduction to Azure Data Lake and U-SQL for SQL users (SQL Saturday 635)Introduction to Azure Data Lake and U-SQL for SQL users (SQL Saturday 635)
Introduction to Azure Data Lake and U-SQL for SQL users (SQL Saturday 635)Michael Rys
 
Sql server introduction
Sql server introductionSql server introduction
Sql server introductionRiteshkiit
 
Oracle Course
Oracle CourseOracle Course
Oracle Courserspaike
 
ONE FOR ALL! Using Apache Calcite to make SQL smart
ONE FOR ALL! Using Apache Calcite to make SQL smartONE FOR ALL! Using Apache Calcite to make SQL smart
ONE FOR ALL! Using Apache Calcite to make SQL smartEvans Ye
 
Top 10 Oracle SQL tuning tips
Top 10 Oracle SQL tuning tipsTop 10 Oracle SQL tuning tips
Top 10 Oracle SQL tuning tipsNirav Shah
 
Advance Hive, NoSQL Database (HBase) - Module 7
Advance Hive, NoSQL Database (HBase) - Module 7Advance Hive, NoSQL Database (HBase) - Module 7
Advance Hive, NoSQL Database (HBase) - Module 7Rohit Agrawal
 

La actualidad más candente (19)

Useful PL/SQL Supplied Packages
Useful PL/SQL Supplied PackagesUseful PL/SQL Supplied Packages
Useful PL/SQL Supplied Packages
 
Myth busters - performance tuning 102 2008
Myth busters - performance tuning 102 2008Myth busters - performance tuning 102 2008
Myth busters - performance tuning 102 2008
 
San diegophp
San diegophpSan diegophp
San diegophp
 
Goldilocks and the Three MySQL Queries
Goldilocks and the Three MySQL QueriesGoldilocks and the Three MySQL Queries
Goldilocks and the Three MySQL Queries
 
B+Tree Indexes and InnoDB
B+Tree Indexes and InnoDBB+Tree Indexes and InnoDB
B+Tree Indexes and InnoDB
 
Part5 sql tune
Part5 sql tunePart5 sql tune
Part5 sql tune
 
Columnstore indexes in sql server 2014
Columnstore indexes in sql server 2014Columnstore indexes in sql server 2014
Columnstore indexes in sql server 2014
 
How to Analyze and Tune MySQL Queries for Better Performance
How to Analyze and Tune MySQL Queries for Better PerformanceHow to Analyze and Tune MySQL Queries for Better Performance
How to Analyze and Tune MySQL Queries for Better Performance
 
U-SQL Does SQL (SQLBits 2016)
U-SQL Does SQL (SQLBits 2016)U-SQL Does SQL (SQLBits 2016)
U-SQL Does SQL (SQLBits 2016)
 
Query Optimization in SQL Server
Query Optimization in SQL ServerQuery Optimization in SQL Server
Query Optimization in SQL Server
 
Cost-based Query Optimization
Cost-based Query Optimization Cost-based Query Optimization
Cost-based Query Optimization
 
SQL Pass Summit Presentations from Datavail - Optimize SQL Server: Query Tuni...
SQL Pass Summit Presentations from Datavail - Optimize SQL Server: Query Tuni...SQL Pass Summit Presentations from Datavail - Optimize SQL Server: Query Tuni...
SQL Pass Summit Presentations from Datavail - Optimize SQL Server: Query Tuni...
 
Rdbms
RdbmsRdbms
Rdbms
 
Introduction to Azure Data Lake and U-SQL for SQL users (SQL Saturday 635)
Introduction to Azure Data Lake and U-SQL for SQL users (SQL Saturday 635)Introduction to Azure Data Lake and U-SQL for SQL users (SQL Saturday 635)
Introduction to Azure Data Lake and U-SQL for SQL users (SQL Saturday 635)
 
Sql server introduction
Sql server introductionSql server introduction
Sql server introduction
 
Oracle Course
Oracle CourseOracle Course
Oracle Course
 
ONE FOR ALL! Using Apache Calcite to make SQL smart
ONE FOR ALL! Using Apache Calcite to make SQL smartONE FOR ALL! Using Apache Calcite to make SQL smart
ONE FOR ALL! Using Apache Calcite to make SQL smart
 
Top 10 Oracle SQL tuning tips
Top 10 Oracle SQL tuning tipsTop 10 Oracle SQL tuning tips
Top 10 Oracle SQL tuning tips
 
Advance Hive, NoSQL Database (HBase) - Module 7
Advance Hive, NoSQL Database (HBase) - Module 7Advance Hive, NoSQL Database (HBase) - Module 7
Advance Hive, NoSQL Database (HBase) - Module 7
 

Destacado (12)

Steps towards of sql server developer
Steps towards of sql server developerSteps towards of sql server developer
Steps towards of sql server developer
 
Dbms objective and subjective notes
Dbms objective and subjective notesDbms objective and subjective notes
Dbms objective and subjective notes
 
Rman offline backup
Rman offline backupRman offline backup
Rman offline backup
 
Rmanpres
RmanpresRmanpres
Rmanpres
 
5 backuprecoveryw imp
5 backuprecoveryw imp5 backuprecoveryw imp
5 backuprecoveryw imp
 
Oracle shutdown
Oracle shutdownOracle shutdown
Oracle shutdown
 
Data guard
Data guardData guard
Data guard
 
1 plsql introduction1
1 plsql introduction11 plsql introduction1
1 plsql introduction1
 
Dba in 2 days unit no 9
Dba in 2 days unit no 9Dba in 2 days unit no 9
Dba in 2 days unit no 9
 
Resize sga
Resize sgaResize sga
Resize sga
 
Store programs
Store programsStore programs
Store programs
 
Database index by Reema Gajjar
Database index by Reema GajjarDatabase index by Reema Gajjar
Database index by Reema Gajjar
 

Similar a Tunning overview

Sql query performance analysis
Sql query performance analysisSql query performance analysis
Sql query performance analysisRiteshkiit
 
Sql query performance analysis
Sql query performance analysisSql query performance analysis
Sql query performance analysisRiteshkiit
 
AWS June 2016 Webinar Series - Amazon Redshift or Big Data Analytics
AWS June 2016 Webinar Series - Amazon Redshift or Big Data AnalyticsAWS June 2016 Webinar Series - Amazon Redshift or Big Data Analytics
AWS June 2016 Webinar Series - Amazon Redshift or Big Data AnalyticsAmazon Web Services
 
SQL Explore 2012: P&T Part 2
SQL Explore 2012: P&T Part 2SQL Explore 2012: P&T Part 2
SQL Explore 2012: P&T Part 2sqlserver.co.il
 
Getting to know oracle database objects iot, mviews, clusters and more…
Getting to know oracle database objects iot, mviews, clusters and more…Getting to know oracle database objects iot, mviews, clusters and more…
Getting to know oracle database objects iot, mviews, clusters and more…Aaron Shilo
 
A tour of Amazon Redshift
A tour of Amazon RedshiftA tour of Amazon Redshift
A tour of Amazon RedshiftKel Graham
 
Amazon Redshift: Performance Tuning and Optimization
Amazon Redshift: Performance Tuning and OptimizationAmazon Redshift: Performance Tuning and Optimization
Amazon Redshift: Performance Tuning and OptimizationAmazon Web Services
 
10 Reasons to Start Your Analytics Project with PostgreSQL
10 Reasons to Start Your Analytics Project with PostgreSQL10 Reasons to Start Your Analytics Project with PostgreSQL
10 Reasons to Start Your Analytics Project with PostgreSQLSatoshi Nagayasu
 
30334823 my sql-cluster-performance-tuning-best-practices
30334823 my sql-cluster-performance-tuning-best-practices30334823 my sql-cluster-performance-tuning-best-practices
30334823 my sql-cluster-performance-tuning-best-practicesDavid Dhavan
 
Database Performance
Database PerformanceDatabase Performance
Database PerformanceBoris Hristov
 
Pl sql best practices document
Pl sql best practices documentPl sql best practices document
Pl sql best practices documentAshwani Pandey
 
AWS (Amazon Redshift) presentation
AWS (Amazon Redshift) presentationAWS (Amazon Redshift) presentation
AWS (Amazon Redshift) presentationVolodymyr Rovetskiy
 
Data Never Lies Presentation for beginners in data field.pptx
Data Never Lies Presentation for beginners in data field.pptxData Never Lies Presentation for beginners in data field.pptx
Data Never Lies Presentation for beginners in data field.pptxTusharAgarwal49094
 
(BDT401) Amazon Redshift Deep Dive: Tuning and Best Practices
(BDT401) Amazon Redshift Deep Dive: Tuning and Best Practices(BDT401) Amazon Redshift Deep Dive: Tuning and Best Practices
(BDT401) Amazon Redshift Deep Dive: Tuning and Best PracticesAmazon Web Services
 
MySQL: Know more about open Source Database
MySQL: Know more about open Source DatabaseMySQL: Know more about open Source Database
MySQL: Know more about open Source DatabaseMahesh Salaria
 
SQLDay2013_Denny Cherry - Table indexing for the .NET Developer
SQLDay2013_Denny Cherry - Table indexing for the .NET DeveloperSQLDay2013_Denny Cherry - Table indexing for the .NET Developer
SQLDay2013_Denny Cherry - Table indexing for the .NET DeveloperPolish SQL Server User Group
 

Similar a Tunning overview (20)

Sql query performance analysis
Sql query performance analysisSql query performance analysis
Sql query performance analysis
 
Sql query performance analysis
Sql query performance analysisSql query performance analysis
Sql query performance analysis
 
AWS June 2016 Webinar Series - Amazon Redshift or Big Data Analytics
AWS June 2016 Webinar Series - Amazon Redshift or Big Data AnalyticsAWS June 2016 Webinar Series - Amazon Redshift or Big Data Analytics
AWS June 2016 Webinar Series - Amazon Redshift or Big Data Analytics
 
SQL Explore 2012: P&T Part 2
SQL Explore 2012: P&T Part 2SQL Explore 2012: P&T Part 2
SQL Explore 2012: P&T Part 2
 
Getting to know oracle database objects iot, mviews, clusters and more…
Getting to know oracle database objects iot, mviews, clusters and more…Getting to know oracle database objects iot, mviews, clusters and more…
Getting to know oracle database objects iot, mviews, clusters and more…
 
Lecture3.ppt
Lecture3.pptLecture3.ppt
Lecture3.ppt
 
A tour of Amazon Redshift
A tour of Amazon RedshiftA tour of Amazon Redshift
A tour of Amazon Redshift
 
Amazon Redshift: Performance Tuning and Optimization
Amazon Redshift: Performance Tuning and OptimizationAmazon Redshift: Performance Tuning and Optimization
Amazon Redshift: Performance Tuning and Optimization
 
Deep Dive on Amazon Redshift
Deep Dive on Amazon RedshiftDeep Dive on Amazon Redshift
Deep Dive on Amazon Redshift
 
10 Reasons to Start Your Analytics Project with PostgreSQL
10 Reasons to Start Your Analytics Project with PostgreSQL10 Reasons to Start Your Analytics Project with PostgreSQL
10 Reasons to Start Your Analytics Project with PostgreSQL
 
Deep Dive on Amazon Redshift
Deep Dive on Amazon RedshiftDeep Dive on Amazon Redshift
Deep Dive on Amazon Redshift
 
30334823 my sql-cluster-performance-tuning-best-practices
30334823 my sql-cluster-performance-tuning-best-practices30334823 my sql-cluster-performance-tuning-best-practices
30334823 my sql-cluster-performance-tuning-best-practices
 
Database Performance
Database PerformanceDatabase Performance
Database Performance
 
Pl sql best practices document
Pl sql best practices documentPl sql best practices document
Pl sql best practices document
 
AWS (Amazon Redshift) presentation
AWS (Amazon Redshift) presentationAWS (Amazon Redshift) presentation
AWS (Amazon Redshift) presentation
 
Data Never Lies Presentation for beginners in data field.pptx
Data Never Lies Presentation for beginners in data field.pptxData Never Lies Presentation for beginners in data field.pptx
Data Never Lies Presentation for beginners in data field.pptx
 
(BDT401) Amazon Redshift Deep Dive: Tuning and Best Practices
(BDT401) Amazon Redshift Deep Dive: Tuning and Best Practices(BDT401) Amazon Redshift Deep Dive: Tuning and Best Practices
(BDT401) Amazon Redshift Deep Dive: Tuning and Best Practices
 
Cassandra training
Cassandra trainingCassandra training
Cassandra training
 
MySQL: Know more about open Source Database
MySQL: Know more about open Source DatabaseMySQL: Know more about open Source Database
MySQL: Know more about open Source Database
 
SQLDay2013_Denny Cherry - Table indexing for the .NET Developer
SQLDay2013_Denny Cherry - Table indexing for the .NET DeveloperSQLDay2013_Denny Cherry - Table indexing for the .NET Developer
SQLDay2013_Denny Cherry - Table indexing for the .NET Developer
 

Más de Hitesh Kumar Markam

Más de Hitesh Kumar Markam (9)

Concepts of Distributed Computing & Cloud Computing
Concepts of Distributed Computing & Cloud Computing Concepts of Distributed Computing & Cloud Computing
Concepts of Distributed Computing & Cloud Computing
 
Log miner in oracle.ppt
Log miner in oracle.pptLog miner in oracle.ppt
Log miner in oracle.ppt
 
Pl sql
Pl sqlPl sql
Pl sql
 
Oracle archi ppt
Oracle archi pptOracle archi ppt
Oracle archi ppt
 
Lecture2 oracle ppt
Lecture2 oracle pptLecture2 oracle ppt
Lecture2 oracle ppt
 
Dba in 2 days
Dba in 2 daysDba in 2 days
Dba in 2 days
 
Creating database
Creating databaseCreating database
Creating database
 
javascript code for mysql database connection
javascript code for mysql database connectionjavascript code for mysql database connection
javascript code for mysql database connection
 
Advanced Planning And Optimization
Advanced Planning And OptimizationAdvanced Planning And Optimization
Advanced Planning And Optimization
 

Último

Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...Association for Project Management
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxVishalSingh1417
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentationcamerronhm
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.MaryamAhmad92
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdfQucHHunhnh
 
Single or Multiple melodic lines structure
Single or Multiple melodic lines structureSingle or Multiple melodic lines structure
Single or Multiple melodic lines structuredhanjurrannsibayan2
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptxMaritesTamaniVerdade
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...Poonam Aher Patil
 
Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsKarakKing
 
Towards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxTowards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxJisc
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...Nguyen Thanh Tu Collection
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxVishalSingh1417
 
Google Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxGoogle Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxDr. Sarita Anand
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17Celine George
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.christianmathematics
 
Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseAnaAcapella
 
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxEsquimalt MFRC
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...christianmathematics
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Jisc
 

Último (20)

Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentation
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
Single or Multiple melodic lines structure
Single or Multiple melodic lines structureSingle or Multiple melodic lines structure
Single or Multiple melodic lines structure
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...
 
Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functions
 
Towards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxTowards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptx
 
Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptx
 
Google Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxGoogle Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptx
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please Practise
 
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)
 

Tunning overview

  • 2. Tuning: overview • • • • • • • • • • • • Rewrite SQL (Leccotech) Create Index Redefine Main memory structures (SGA in Oracle) Change the Block Size Materialized Views, Denormalization Export/Import (drop indexes): defragment Check Locks Separate data by category in proper tablespaces Partition Database Redundant Arrays of Inexpensive Disks (RAID) Redefining Client-Server Architecture Buy Hardware
  • 3. When to Index • Large tables A field that you query by frequently • Field with high cardinality (not sex where card. Is only 2) • Smaller Fields and Fixed length are preferred. (Obs:Most DBMSs automatically index PK)
  • 4. Different Type of Indexes • • • • • B-Trees (traditional) indexes Hash-cluster Bitmap indexes Index-Organized Tables Reverse-Key Indexes
  • 5. Create Index command • Create index <iName> on <tname> (<col_name>); • Create index cidx on orders (cid);
  • 6. Why do we create an index ? (OLTP x Data Warehouse) • A) To speed up query (SELECT) ? • B) To speed up data entry (insert/update/delete) ? • C) All of the above ?
  • 7. Indexes (Defaults) • Anytime a PK is created, an index is automatically created. • Anytime when the type of index is not specificied, the type of index created is a B-Trees.
  • 8. B-Tree (Balanced Tree) • Most popular type of index structure for any programming language or database. • When you don’t know what to do, the best option is usually a B-Tree. They are flexible and perform well (not very well) in several scenarios. • It is really the B+ tree or B* tree
  • 9. B-Trees (continued) • One node corresponds to one block/page (minimum disk I-O). • Non-Leaf nodes(n keys, n+1 pointers) • Leaf-Nodes (contain n entries, where each entry has an index and a pointer to a data block). Also, each node has a pointer to next node. • All leaves are at the same height.
  • 10. Good Indexing (B-Tree) Candidates • Table must be reasonably large • Field is queried by frequently • Field has a high cardinality (don’t index by sex, where the cardinality is 2!!). • Badly balanced trees may inhibit performance. Destroying and re-creating index may improve performance.
  • 11. Bitmap Index • Bitmap indexes contain the key value and a bitmap listing the value of 0 or 1 (yes/no) for each row indicating whether the row contains that value or not. • May be a good option for indexing fields that have low cardinality (opposite of B-trees).
  • 12. Bitmap Index (cont.) • Syntax: Create Bitmap index …. • Bitmap index works better with equality tests = or in (not with < or > ) • Bitmap index maintenance can be expensive; an individual bit may not be locked; a single update locks a large portion of index. • Bitmap indexes are best in read-only datawarehouse situations
  • 13. Hash Indexing • B-trees and Bitmap index keys are used to find rows requiring I/O to process index • Hash gets rows with a key based algorithm • Rows are stored based on a hashed value • Index size should be known at index creation • Example: – create index cidx on orders (cid) hashed;
  • 14. Hash Index work best with • • • • Very-high cardinality columns Only equal (=) tests are used Index values do not change Number of rows are known ahead of time
  • 15. Index-Organized Tables • Table data is incorporated into the B-Tree using the PK as the index. • Table data is always in order of PK. Many sorts can be avoided. • Index works best when there are few (and small) columns in your table other than the PK.
  • 16. Reverse Key Indexes • Key ‘1234’ becomes ‘4321’, etc. • Only efficient for few scenarios involving parallel processing and a huge amount of data. • By reversing key values, index blocks might be more evenly distributed reducing the likelihood of densely or sparsely populated indexes.
  • 17. Conclusions on Indexes • For high-cardinality key values, B-Tree indexes are usually best. • B-Trees work with all types of comparisons and gracefully shrink and grow as table changes. • For low cardinality read-only environments, Bitmaps may be a good option.
  • 18. Query Optimizer • A query optimizer parsers your SQL/Query into a sequence of relational algebra operations, determining an execution plan. • The query optimizer figures out the best execution plan based on rules of thumb and information provided in the Data Dictionary (System catalog).
  • 19. Oracle Query Optimizer • Up to version 6, Oracle Used a Rule Based Optimizer. After version 6, Oracle offered the Cost Based and the Rule Based Optimizer. The default is now the Cost Based Optimizer.
  • 20. Query Optimizer • To view how the query plan you must use either set autotrace on or explain plan. Set autotrace on is much simpler. Explain plan is a little bit more efficient, but more complicated.
  • 21. Typical SQL operations (results of autotrace) • • • • • TABLE ACCESS FULL TABLE ACCESS BY ROWID INDEX RANGE SCAN INDEX UNIQUE SCAN NESTED LOOPS
  • 22. • TABLE ACCESS FULL (full table scan): Oracle will look at every row in the table to find the requested information. This is usually the slowest way to access a table.
  • 23. TABLE ACCESS BY ROWID Oracle will use the ROWID method to find a row in the table. ROWID is a special column detailing an exact Oracle block where the row can be found. This is the fastest way to access a table (faster than any index. Less flexible than any index).
  • 24. INDEX RANGE SCAN Oracle will search an index for a range of values. Usually, this even occurs when a range or between operation is specified by the query or when only the leading columns in a composite index are specified by the where clause. Can perform well or poorly, based on the size of the range and the fragmentation of the index.).
  • 25. INDEX UNIQUE SCAN Oracle will perform this operation when the table’s primary key or a unique key is part of the where clause. This is the most efficient way to search an index.
  • 26. NESTED LOOPS Indicates that a join operation is occurring. Can perform well or poorly, depending on performance on the index and table operations of the individual tables being joined.
  • 27. Tuning SQL and PL/SQL Queries Sometimes, Same Query written more than 1000 ways. Generating more than 100 execution plans. Some firms have products that re-write correctly written SQL queries automatically. Select emp_sal from emp where emp_id exists (select emp_id from dept where deptname like’mca’);
  • 28. ROWID • SELECT ROWID, … INTO :EMP_ROWID, … FROM EMP WHERE EMP.EMP_NO = 56722 FOR UPDATE; UPDATE EMP SET EMP.NAME = … WHERE ROWID = :EMP_ROWID;
  • 29. ROWID (cont.) • Fastest • Less Flexible • Are very useful for removing duplicates of rows
  • 30. SELECT STATEMENT • • • • • • Not exists in place of NOT IN Joins in place of Exists Avoid sub-selects Exists in place of distinct UNION in place of OR on an index column WHERE instead of ORDER BY