SlideShare a Scribd company logo
1 of 41
Download to read offline
INDEXING STRATEGIES
Sean Scott
Oracle DBA, Bodybuilding.com
“An index is an optional structure, associated with a table or table
cluster, that can sometimes speed data access.”
B-TREE INDEXES
• Most common type of index
• Data is ordered within the index
• Consists of branches and leaves
B-TREE INDEXES
B-TREE INDEXES
• Options include
• Unique
• Descending
• Reverse Key
• Index Organized Tables
• Composite, Covering, Concatenated
• Compressed
REVERSE KEY INDEXES
• Creates a “mirror image” of the key
• UTOUG would become GUOTU
• Used to spread block splits and avoid hot blocks in RAC environments
• No index range scans
• Lots of conflicting information
• Test extensively, and use with caution
REVERSE KEY INDEXES
• Two implementations:
• last_updated_date in a customer order table
• Sequentially updated primary key
REVERSE KEY INDEXES
• Things to watch for:
• Increase in db sequential read wait events
• Backup time increase
• Space use increase
INDEX ORGANIZED TABLES
• Stores data and index in the same segment
• Must have a primary key
• Data is ordered
• Can have secondary indexes
• Useful for tables that are fully accessed
• Overflow for less-used data
COMPOSITE INDEXES
• Sometimes known as covering or concatenated
• Consist of more than one column
• Leading column is important
COMPOSITE INDEXES
create index test_i1
on test(col1);
create index test_i2
on test(col1, col2);
COMPOSITE INDEXES
• Choosing a leading column
• High cardinality?
• Low cardinality?
• Most frequently accessed
• The Poor-Man’s IOT
• Use to improve performance of select by reducing I/O
COVERING INDEXES
 SELECT price_id
,         price 
     FROM dcs_price
    WHERE version_id       = :1
      AND price_id           = :2;
-------------------------------------------------------------------------------------------
| Id  | Operation                   | Name        | Rows  | Bytes | Cost (%CPU)| Time     |
-------------------------------------------------------------------------------------------
|   0 | SELECT STATEMENT            |             |     1 |    29 |     5   (0)| 00:00:01 |
|*  1 |  TABLE ACCESS BY INDEX ROWID| DCS_PRICE   |     1 |    29 |     5   (0)| 00:00:01 |
|*  2 |   INDEX RANGE SCAN          | DCS_PRICE_P |     2 |       |     3   (0)| 00:00:01 |
-------------------------------------------------------------------------------------------
create unique index dcs_price_i3
      on dcs_price (
price_id
, version_id
, price);
-----------------------------------------------------------------------------------
| Id  | Operation        | Name           | Rows  | Bytes | Cost (%CPU)| Time     |
-----------------------------------------------------------------------------------
|   0 | SELECT STATEMENT |                |     1 |    22 |     2   (0)| 00:00:01 |
|*  1 |  INDEX RANGE SCAN| DCS_PRICE_I03 |     1 |    22 |     2   (0)| 00:00:01 |
-----------------------------------------------------------------------------------
COMPRESSED KEY INDEXES
• Leading columns have low cardinality
• Save space
• Improve performance
BITMAP INDEXES
• Index on low cardinality data
• Take up little space
• Bitmap join
• Typically found in data warehouse environments
FUNCTION BASED, INDEXEDVIRTUAL
• Index on a database function (predefined, user written)
• Allows index lookups when a function is used
• Both store the derived value in the index
INVISIBLE INDEXES
• Create or modify an index to be invisible
• Invisible to the optimizer
• Still maintained by the database
• Better, more reliable option than MONITORING USAGE
• Must set optimizer_use_invisible_indexes=TRUE
VIRTUAL INDEXES
• Only visible to the optimizer
• Used for evaluating an indexes usefulness
VIRTUAL INDEXES
SQL> create table test (col1 integer);
Table created.
SQL> create index test_i1 on test(col1);
Index created.
SQL> create index test_i2 on test(col1);
create index test_i2 on test(col1)
*
ERROR at line 1:
ORA-01408: such column list already indexed
VIRTUAL INDEXES
SQL> create index test_i2 on test(col1) nosegment;
Index created.
SQL> select table_name, index_name, column_name from user_ind_columns where
table_name = 'TEST';
TABLE_NAME INDEX_NAME COLUMN_NAME
------------------------------ ------------------------------ --------------------
TEST TEST_I1 COL1
TEST TEST_I2 COL1
CLUSTER INDEXES
• B-Tree Cluster Index
• Hash Cluster Index
• Hash clusters can exist on a single table
PARTITIONED INDEXES
• Global Partitioned
• Crosses partitions
• Exists on whole table
• Local Partitioned
• Unique to each partition
• Watch out for non-partitioned indexes on partitions
PARTITIONED INDEXES
• Locally partitioned indexes
• Isolate maintenance operations to a single partition
• Mark unusable/invisible independently
• Separate partitions into different tablespaces
• Prefixed, non-prefixed
• Unique indexes must include partition key
• Can only exist on partitioned tables
PARTITIONED INDEXES
• Globally partitioned indexes
• Can exist on non-partitioned tables
• Can be either range or hash based
• Partition maintenance can render the index unusable
• Global indexes on partitioned tables must lead with the partition key
PARTITIONED INDEXES
Local partition
Partition index unusable
Partition index unusable
Partitions involved unusable
Partition index unusable
No effect on index
No effect on index
Global or non-partition
Entire index unusable
Entire index unusable
Entire index unusable
Entire index unusable
Entire index unusable
Entire index unusable
Operation
Split
Move
Merge
Exchange
Truncate
Drop
WHAT TO INDEX
• Primary keys
• Unique keys
• Foreign keys
• Columns frequently used in where, distinct, and order by clauses
• Columns often queried together
Index all that should be, and no more.
If in doubt, b-tree is probably safest.
KEY CONSIDERATIONS
Create primary and unique keys within a create table or build the indexes
and constraints separately?
The create table method is easier, but:
• Indexes don’t persist
• May break GoldenGate, replication
create table test1 (
col1 integer);
create unique index
test1_p
on test1(col1);
alter table test1
add constraint
test1_p
primary key
(col1)
using index test1_p;
create table test2 (
col1 integer
primary key);
-or-
create table test2 (
col1 integer,
constraint test2_p
primary key
(col1));
select table_name, index_name
from dba_indexes
where table_name like 'TEST%';
TEST2 SYS_C0015135
TEST1 TEST1_P
alter table test1
drop constraint test1_p;
alter table test2
drop constraint SYS_C0015135;
select table_name, index_name
from dba_indexes
where table_name like 'TEST%';
TEST1 TEST1_P
• Pick a convention and stick to it!
• tablename_p
• tablename_un
• tablename_in
• tablename_fn
• tablename_bn
• ...etc
NAMING CONVENTION
--------------------------------------------------------------------------------------------------------
| Id | Operation" " " "" " " | Name" " " | Rows | Bytes| Cost (%CPU)| Time " |
--------------------------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT"" "" " " |" " " " | 30| 4230| 560 (1)| 00:00:07|
| 1 | SORT ORDER BY" " " "" " |" " " " | 30| 4230| 560 (1)| 00:00:07|
| 2 | NESTED LOOPS" " " "" " |" " " " | 30| 4230| 559 (1)| 00:00:07|
| 3 | NESTED LOOPS "" "" " " |" " " " | 30| 3630| 552 (1)| 00:00:07|
| 4 | NESTED LOOPS"" "" " " |" " " " | 30| 2790| 544 (1)| 00:00:07|
| 5 | MERGE JOIN "" "" " " |" " " " | 30| 1290| 537 (1)| 00:00:07|
|* 6 | TABLE ACCESS BY INDEX ROWID " | TICKET_STATUSES" | 7| 42| 1 (0)| 00:00:01|
|* 7 | INDEX FULL SCAN" " "" | SYS_C0107546 | 10| | 1 (0)| 00:00:01|
|* 8 | SORT JOIN "" "" " " |" " " " | 35| 1295| 536 (1)| 00:00:07|
|* 9 | TABLE ACCESS BY INDEX ROWID " | TICKETS"" " | 35| 1295| 535 (1)| 00:00:07|
| 10 | " BITMAP CONVERSION TO ROWIDS " " |" " " " | | |" " |" " |
| 11 | " BITMAP AND" " "" " " |" " " " | | |" " " |" " |
| 12 | " BITMAP MINUS" " "" " |" " " " | | |" " | " " |
|* 13 | " BITMAP INDEX SINGLE VALUE" " | TICKETS1 " | | |" " | " " |
|* 14 | " BITMAP INDEX SINGLE VALUE" " | IDX_TICKETS_I01 "| | |" " " | " " |
|* 15 | " BITMAP INDEX SINGLE VALUE " " | TICKETS_INDEX | | |" " " |" " |
| 16 | TABLE ACCESS BY INDEX ROWID " | PANELS"" " | 1| 50| 1 (0)| 00:00:01|
|* 17 | INDEX UNIQUE SCAN " "" " | SYS_C0367234 " | 1| | 1 (0)| 00:00:01|
| 18 | TABLE ACCESS BY INDEX ROWID " | USERS" " " | 1| 28| 1 (0)| 00:00:01|
|* 19 | INDEX UNIQUE SCAN" " "" | SYS_C0038942" | 1| | 1 (0)| 00:00:01|
| 20 | TABLE ACCESS BY INDEX ROWID" "" | CUSTOMERS " " | 1| 20| 1 (0)| 00:00:01|
|* 21 | INDEX UNIQUE SCAN"" "" " | SYS_C8712300" | 1| | 1 (0)| 00:00:01|
--------------------------------------------------------------------------------------------------------
STORAGE
• Consider separating table and index tablespaces
• Specify suitable storage parameters
• PCTFREE is meaningless in indexes
• logging/nologging
• Extent and block size can be defined
• Manage backups
• Manage physical storage
• Index reorganization options
• alter index rebuild
• alter index coalesce
• alter index shrink space (compact)
MAINTENANCE
• Use DBMS_STATS
• Defaults are usually best:
exec dbms_stats.set_global_prefs(‘METHOD_OPT’, ‘FOR ALL COLUMNS SIZE AUTO’);
exec dbms_stats.reset_global_pref_defaults;
• CASCADE=TRUE
structureddata.org/2008/10/14/dbms_stats-method_opt-and-for-all-indexed-columns/
GENERATING STATISTICS
• Introduced in 11g
• Allows you to create column groups
• Determines a relationship among potentially skewed data
dbms_stats.create_extended_stats(
‘APP’, ‘CUSTOMERS’, ‘(BIRTHDATE, BIRTHSTONE)’);
EXTENDED STATISTICS
oracle.sean@gmail.com
sean.scott@bodybuilding.com
github.com/oraclesean/oracle

More Related Content

What's hot

Ash masters : advanced ash analytics on Oracle
Ash masters : advanced ash analytics on Oracle Ash masters : advanced ash analytics on Oracle
Ash masters : advanced ash analytics on Oracle Kyle Hailey
 
Performance Stability, Tips and Tricks and Underscores
Performance Stability, Tips and Tricks and UnderscoresPerformance Stability, Tips and Tricks and Underscores
Performance Stability, Tips and Tricks and UnderscoresJitendra Singh
 
Tuning SQL for Oracle Exadata: The Good, The Bad, and The Ugly Tuning SQL fo...
 Tuning SQL for Oracle Exadata: The Good, The Bad, and The Ugly Tuning SQL fo... Tuning SQL for Oracle Exadata: The Good, The Bad, and The Ugly Tuning SQL fo...
Tuning SQL for Oracle Exadata: The Good, The Bad, and The Ugly Tuning SQL fo...Enkitec
 
SQL Macros - Game Changing Feature for SQL Developers?
SQL Macros - Game Changing Feature for SQL Developers?SQL Macros - Game Changing Feature for SQL Developers?
SQL Macros - Game Changing Feature for SQL Developers?Andrej Pashchenko
 
Understanding SQL Trace, TKPROF and Execution Plan for beginners
Understanding SQL Trace, TKPROF and Execution Plan for beginnersUnderstanding SQL Trace, TKPROF and Execution Plan for beginners
Understanding SQL Trace, TKPROF and Execution Plan for beginnersCarlos Sierra
 
Troubleshooting Complex Performance issues - Oracle SEG$ contention
Troubleshooting Complex Performance issues - Oracle SEG$ contentionTroubleshooting Complex Performance issues - Oracle SEG$ contention
Troubleshooting Complex Performance issues - Oracle SEG$ contentionTanel Poder
 
MySQL Query And Index Tuning
MySQL Query And Index TuningMySQL Query And Index Tuning
MySQL Query And Index TuningManikanda kumar
 
Performance Tuning With Oracle ASH and AWR. Part 1 How And What
Performance Tuning With Oracle ASH and AWR. Part 1 How And WhatPerformance Tuning With Oracle ASH and AWR. Part 1 How And What
Performance Tuning With Oracle ASH and AWR. Part 1 How And Whatudaymoogala
 
Oracle_Multitenant_19c_-_All_About_Pluggable_D.pdf
Oracle_Multitenant_19c_-_All_About_Pluggable_D.pdfOracle_Multitenant_19c_-_All_About_Pluggable_D.pdf
Oracle_Multitenant_19c_-_All_About_Pluggable_D.pdfSrirakshaSrinivasan2
 
Oracle Exadata - Issues and Challenges
Oracle Exadata - Issues and ChallengesOracle Exadata - Issues and Challenges
Oracle Exadata - Issues and Challengescomahony
 
Getting optimal performance from oracle e-business suite presentation
Getting optimal performance from oracle e-business suite presentationGetting optimal performance from oracle e-business suite presentation
Getting optimal performance from oracle e-business suite presentationBerry Clemens
 
Tanel Poder - Performance stories from Exadata Migrations
Tanel Poder - Performance stories from Exadata MigrationsTanel Poder - Performance stories from Exadata Migrations
Tanel Poder - Performance stories from Exadata MigrationsTanel Poder
 
MySQL8.0_performance_schema.pptx
MySQL8.0_performance_schema.pptxMySQL8.0_performance_schema.pptx
MySQL8.0_performance_schema.pptxNeoClova
 
OOW15 - technical upgrade best practices for oracle e-business suite 12.2
OOW15 - technical upgrade best practices for oracle e-business suite 12.2OOW15 - technical upgrade best practices for oracle e-business suite 12.2
OOW15 - technical upgrade best practices for oracle e-business suite 12.2vasuballa
 
Chasing the optimizer
Chasing the optimizerChasing the optimizer
Chasing the optimizerMauro Pagano
 
SQL Plan Directives explained
SQL Plan Directives explainedSQL Plan Directives explained
SQL Plan Directives explainedMauro Pagano
 
SQL Monitoring in Oracle Database 12c
SQL Monitoring in Oracle Database 12cSQL Monitoring in Oracle Database 12c
SQL Monitoring in Oracle Database 12cTanel Poder
 
Troubleshooting Complex Oracle Performance Problems with Tanel Poder
Troubleshooting Complex Oracle Performance Problems with Tanel PoderTroubleshooting Complex Oracle Performance Problems with Tanel Poder
Troubleshooting Complex Oracle Performance Problems with Tanel PoderTanel Poder
 

What's hot (20)

Ash masters : advanced ash analytics on Oracle
Ash masters : advanced ash analytics on Oracle Ash masters : advanced ash analytics on Oracle
Ash masters : advanced ash analytics on Oracle
 
Performance Stability, Tips and Tricks and Underscores
Performance Stability, Tips and Tricks and UnderscoresPerformance Stability, Tips and Tricks and Underscores
Performance Stability, Tips and Tricks and Underscores
 
Tuning SQL for Oracle Exadata: The Good, The Bad, and The Ugly Tuning SQL fo...
 Tuning SQL for Oracle Exadata: The Good, The Bad, and The Ugly Tuning SQL fo... Tuning SQL for Oracle Exadata: The Good, The Bad, and The Ugly Tuning SQL fo...
Tuning SQL for Oracle Exadata: The Good, The Bad, and The Ugly Tuning SQL fo...
 
SQL Macros - Game Changing Feature for SQL Developers?
SQL Macros - Game Changing Feature for SQL Developers?SQL Macros - Game Changing Feature for SQL Developers?
SQL Macros - Game Changing Feature for SQL Developers?
 
Understanding SQL Trace, TKPROF and Execution Plan for beginners
Understanding SQL Trace, TKPROF and Execution Plan for beginnersUnderstanding SQL Trace, TKPROF and Execution Plan for beginners
Understanding SQL Trace, TKPROF and Execution Plan for beginners
 
Troubleshooting Complex Performance issues - Oracle SEG$ contention
Troubleshooting Complex Performance issues - Oracle SEG$ contentionTroubleshooting Complex Performance issues - Oracle SEG$ contention
Troubleshooting Complex Performance issues - Oracle SEG$ contention
 
MySQL Query And Index Tuning
MySQL Query And Index TuningMySQL Query And Index Tuning
MySQL Query And Index Tuning
 
Performance Tuning With Oracle ASH and AWR. Part 1 How And What
Performance Tuning With Oracle ASH and AWR. Part 1 How And WhatPerformance Tuning With Oracle ASH and AWR. Part 1 How And What
Performance Tuning With Oracle ASH and AWR. Part 1 How And What
 
Oracle_Multitenant_19c_-_All_About_Pluggable_D.pdf
Oracle_Multitenant_19c_-_All_About_Pluggable_D.pdfOracle_Multitenant_19c_-_All_About_Pluggable_D.pdf
Oracle_Multitenant_19c_-_All_About_Pluggable_D.pdf
 
Oracle Exadata - Issues and Challenges
Oracle Exadata - Issues and ChallengesOracle Exadata - Issues and Challenges
Oracle Exadata - Issues and Challenges
 
Getting optimal performance from oracle e-business suite presentation
Getting optimal performance from oracle e-business suite presentationGetting optimal performance from oracle e-business suite presentation
Getting optimal performance from oracle e-business suite presentation
 
Tanel Poder - Performance stories from Exadata Migrations
Tanel Poder - Performance stories from Exadata MigrationsTanel Poder - Performance stories from Exadata Migrations
Tanel Poder - Performance stories from Exadata Migrations
 
AWR and ASH Deep Dive
AWR and ASH Deep DiveAWR and ASH Deep Dive
AWR and ASH Deep Dive
 
MySQL8.0_performance_schema.pptx
MySQL8.0_performance_schema.pptxMySQL8.0_performance_schema.pptx
MySQL8.0_performance_schema.pptx
 
OOW15 - technical upgrade best practices for oracle e-business suite 12.2
OOW15 - technical upgrade best practices for oracle e-business suite 12.2OOW15 - technical upgrade best practices for oracle e-business suite 12.2
OOW15 - technical upgrade best practices for oracle e-business suite 12.2
 
Chasing the optimizer
Chasing the optimizerChasing the optimizer
Chasing the optimizer
 
Oracle: Procedures
Oracle: ProceduresOracle: Procedures
Oracle: Procedures
 
SQL Plan Directives explained
SQL Plan Directives explainedSQL Plan Directives explained
SQL Plan Directives explained
 
SQL Monitoring in Oracle Database 12c
SQL Monitoring in Oracle Database 12cSQL Monitoring in Oracle Database 12c
SQL Monitoring in Oracle Database 12c
 
Troubleshooting Complex Oracle Performance Problems with Tanel Poder
Troubleshooting Complex Oracle Performance Problems with Tanel PoderTroubleshooting Complex Oracle Performance Problems with Tanel Poder
Troubleshooting Complex Oracle Performance Problems with Tanel Poder
 

Viewers also liked

Oracle b tree index internals - rebuilding the thruth
Oracle b tree index internals - rebuilding the thruthOracle b tree index internals - rebuilding the thruth
Oracle b tree index internals - rebuilding the thruthXavier Davias
 
Less13 Performance
Less13 PerformanceLess13 Performance
Less13 Performancevivaankumar
 
Oracle Data Redaction
Oracle Data RedactionOracle Data Redaction
Oracle Data RedactionIvica Arsov
 
Oracle Database Performance Tuning Basics
Oracle Database Performance Tuning BasicsOracle Database Performance Tuning Basics
Oracle Database Performance Tuning Basicsnitin anjankar
 
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
 
Oracle Database Management - Backup/Recovery
Oracle Database Management - Backup/RecoveryOracle Database Management - Backup/Recovery
Oracle Database Management - Backup/RecoveryChien Chung Shen
 
Oracle Index
Oracle IndexOracle Index
Oracle IndexJongwon
 
Oracle database performance tuning
Oracle database performance tuningOracle database performance tuning
Oracle database performance tuningYogiji Creations
 

Viewers also liked (8)

Oracle b tree index internals - rebuilding the thruth
Oracle b tree index internals - rebuilding the thruthOracle b tree index internals - rebuilding the thruth
Oracle b tree index internals - rebuilding the thruth
 
Less13 Performance
Less13 PerformanceLess13 Performance
Less13 Performance
 
Oracle Data Redaction
Oracle Data RedactionOracle Data Redaction
Oracle Data Redaction
 
Oracle Database Performance Tuning Basics
Oracle Database Performance Tuning BasicsOracle Database Performance Tuning Basics
Oracle Database Performance Tuning Basics
 
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…
 
Oracle Database Management - Backup/Recovery
Oracle Database Management - Backup/RecoveryOracle Database Management - Backup/Recovery
Oracle Database Management - Backup/Recovery
 
Oracle Index
Oracle IndexOracle Index
Oracle Index
 
Oracle database performance tuning
Oracle database performance tuningOracle database performance tuning
Oracle database performance tuning
 

Similar to Indexing Strategies for Optimal Database Performance

Oracle Query Tuning Tips - Get it Right the First Time
Oracle Query Tuning Tips - Get it Right the First TimeOracle Query Tuning Tips - Get it Right the First Time
Oracle Query Tuning Tips - Get it Right the First TimeDean Richards
 
Sydney Oracle Meetup - access paths
Sydney Oracle Meetup - access pathsSydney Oracle Meetup - access paths
Sydney Oracle Meetup - access pathspaulguerin
 
Five Tips to Get the Most Out of Your Indexing
Five Tips to Get the Most Out of Your IndexingFive Tips to Get the Most Out of Your Indexing
Five Tips to Get the Most Out of Your IndexingMaria Colgan
 
Sql and PL/SQL Best Practices I
Sql and PL/SQL Best Practices ISql and PL/SQL Best Practices I
Sql and PL/SQL Best Practices ICarlos Oliveira
 
Top 10 tips for Oracle performance
Top 10 tips for Oracle performanceTop 10 tips for Oracle performance
Top 10 tips for Oracle performanceGuy Harrison
 
NOCOUG_201311_Fine_Tuning_Execution_Plans.pdf
NOCOUG_201311_Fine_Tuning_Execution_Plans.pdfNOCOUG_201311_Fine_Tuning_Execution_Plans.pdf
NOCOUG_201311_Fine_Tuning_Execution_Plans.pdfcookie1969
 
Enterprise dbs and Database indexing
Enterprise dbs and Database indexingEnterprise dbs and Database indexing
Enterprise dbs and Database indexingabksharma
 
Horizontally Scalable Relational Databases with Spark: Spark Summit East talk...
Horizontally Scalable Relational Databases with Spark: Spark Summit East talk...Horizontally Scalable Relational Databases with Spark: Spark Summit East talk...
Horizontally Scalable Relational Databases with Spark: Spark Summit East talk...Spark Summit
 
Query Optimization with MySQL 5.6: Old and New Tricks
Query Optimization with MySQL 5.6: Old and New TricksQuery Optimization with MySQL 5.6: Old and New Tricks
Query Optimization with MySQL 5.6: Old and New TricksMYXPLAIN
 
Dbms plan - A swiss army knife for performance engineers
Dbms plan - A swiss army knife for performance engineersDbms plan - A swiss army knife for performance engineers
Dbms plan - A swiss army knife for performance engineersRiyaj Shamsudeen
 
12 things Oracle DBAs must know about SQL
12 things Oracle DBAs must know about SQL12 things Oracle DBAs must know about SQL
12 things Oracle DBAs must know about SQLSolarWinds
 
Oracle Diagnostics : Joins - 1
Oracle Diagnostics : Joins - 1Oracle Diagnostics : Joins - 1
Oracle Diagnostics : Joins - 1Hemant K Chitale
 
Managing Statistics for Optimal Query Performance
Managing Statistics for Optimal Query PerformanceManaging Statistics for Optimal Query Performance
Managing Statistics for Optimal Query PerformanceKaren Morton
 
SQL Server 2022 Programmability & Performance
SQL Server 2022 Programmability & PerformanceSQL Server 2022 Programmability & Performance
SQL Server 2022 Programmability & PerformanceGianluca Hotz
 
Oracle performance tuning_sfsf
Oracle performance tuning_sfsfOracle performance tuning_sfsf
Oracle performance tuning_sfsfMao Geng
 
Oracle statistics by example
Oracle statistics by exampleOracle statistics by example
Oracle statistics by exampleMauro Pagano
 
PHP UK 2020 Tutorial: MySQL Indexes, Histograms And other ways To Speed Up Yo...
PHP UK 2020 Tutorial: MySQL Indexes, Histograms And other ways To Speed Up Yo...PHP UK 2020 Tutorial: MySQL Indexes, Histograms And other ways To Speed Up Yo...
PHP UK 2020 Tutorial: MySQL Indexes, Histograms And other ways To Speed Up Yo...Dave Stokes
 
Oracle 122 partitioning_in_action_slide_share
Oracle 122 partitioning_in_action_slide_shareOracle 122 partitioning_in_action_slide_share
Oracle 122 partitioning_in_action_slide_shareThomas Teske
 
Big Data Analytics with MariaDB ColumnStore
Big Data Analytics with MariaDB ColumnStoreBig Data Analytics with MariaDB ColumnStore
Big Data Analytics with MariaDB ColumnStoreMariaDB plc
 

Similar to Indexing Strategies for Optimal Database Performance (20)

Oracle Query Tuning Tips - Get it Right the First Time
Oracle Query Tuning Tips - Get it Right the First TimeOracle Query Tuning Tips - Get it Right the First Time
Oracle Query Tuning Tips - Get it Right the First Time
 
Sydney Oracle Meetup - access paths
Sydney Oracle Meetup - access pathsSydney Oracle Meetup - access paths
Sydney Oracle Meetup - access paths
 
Five Tips to Get the Most Out of Your Indexing
Five Tips to Get the Most Out of Your IndexingFive Tips to Get the Most Out of Your Indexing
Five Tips to Get the Most Out of Your Indexing
 
Sql and PL/SQL Best Practices I
Sql and PL/SQL Best Practices ISql and PL/SQL Best Practices I
Sql and PL/SQL Best Practices I
 
Top 10 tips for Oracle performance
Top 10 tips for Oracle performanceTop 10 tips for Oracle performance
Top 10 tips for Oracle performance
 
NOCOUG_201311_Fine_Tuning_Execution_Plans.pdf
NOCOUG_201311_Fine_Tuning_Execution_Plans.pdfNOCOUG_201311_Fine_Tuning_Execution_Plans.pdf
NOCOUG_201311_Fine_Tuning_Execution_Plans.pdf
 
Enterprise dbs and Database indexing
Enterprise dbs and Database indexingEnterprise dbs and Database indexing
Enterprise dbs and Database indexing
 
Horizontally Scalable Relational Databases with Spark: Spark Summit East talk...
Horizontally Scalable Relational Databases with Spark: Spark Summit East talk...Horizontally Scalable Relational Databases with Spark: Spark Summit East talk...
Horizontally Scalable Relational Databases with Spark: Spark Summit East talk...
 
Query Optimization with MySQL 5.6: Old and New Tricks
Query Optimization with MySQL 5.6: Old and New TricksQuery Optimization with MySQL 5.6: Old and New Tricks
Query Optimization with MySQL 5.6: Old and New Tricks
 
Dbms plan - A swiss army knife for performance engineers
Dbms plan - A swiss army knife for performance engineersDbms plan - A swiss army knife for performance engineers
Dbms plan - A swiss army knife for performance engineers
 
12 things Oracle DBAs must know about SQL
12 things Oracle DBAs must know about SQL12 things Oracle DBAs must know about SQL
12 things Oracle DBAs must know about SQL
 
Oracle Diagnostics : Joins - 1
Oracle Diagnostics : Joins - 1Oracle Diagnostics : Joins - 1
Oracle Diagnostics : Joins - 1
 
Managing Statistics for Optimal Query Performance
Managing Statistics for Optimal Query PerformanceManaging Statistics for Optimal Query Performance
Managing Statistics for Optimal Query Performance
 
SQL Server 2022 Programmability & Performance
SQL Server 2022 Programmability & PerformanceSQL Server 2022 Programmability & Performance
SQL Server 2022 Programmability & Performance
 
Oracle performance tuning_sfsf
Oracle performance tuning_sfsfOracle performance tuning_sfsf
Oracle performance tuning_sfsf
 
Oracle statistics by example
Oracle statistics by exampleOracle statistics by example
Oracle statistics by example
 
Ssn0020 ssis 2012 for beginners
Ssn0020   ssis 2012 for beginnersSsn0020   ssis 2012 for beginners
Ssn0020 ssis 2012 for beginners
 
PHP UK 2020 Tutorial: MySQL Indexes, Histograms And other ways To Speed Up Yo...
PHP UK 2020 Tutorial: MySQL Indexes, Histograms And other ways To Speed Up Yo...PHP UK 2020 Tutorial: MySQL Indexes, Histograms And other ways To Speed Up Yo...
PHP UK 2020 Tutorial: MySQL Indexes, Histograms And other ways To Speed Up Yo...
 
Oracle 122 partitioning_in_action_slide_share
Oracle 122 partitioning_in_action_slide_shareOracle 122 partitioning_in_action_slide_share
Oracle 122 partitioning_in_action_slide_share
 
Big Data Analytics with MariaDB ColumnStore
Big Data Analytics with MariaDB ColumnStoreBig Data Analytics with MariaDB ColumnStore
Big Data Analytics with MariaDB ColumnStore
 

Recently uploaded

Indian Call Girls in Abu Dhabi O5286O24O8 Call Girls in Abu Dhabi By Independ...
Indian Call Girls in Abu Dhabi O5286O24O8 Call Girls in Abu Dhabi By Independ...Indian Call Girls in Abu Dhabi O5286O24O8 Call Girls in Abu Dhabi By Independ...
Indian Call Girls in Abu Dhabi O5286O24O8 Call Girls in Abu Dhabi By Independ...dajasot375
 
办理学位证中佛罗里达大学毕业证,UCF成绩单原版一比一
办理学位证中佛罗里达大学毕业证,UCF成绩单原版一比一办理学位证中佛罗里达大学毕业证,UCF成绩单原版一比一
办理学位证中佛罗里达大学毕业证,UCF成绩单原版一比一F sss
 
Effects of Smartphone Addiction on the Academic Performances of Grades 9 to 1...
Effects of Smartphone Addiction on the Academic Performances of Grades 9 to 1...Effects of Smartphone Addiction on the Academic Performances of Grades 9 to 1...
Effects of Smartphone Addiction on the Academic Performances of Grades 9 to 1...limedy534
 
Identifying Appropriate Test Statistics Involving Population Mean
Identifying Appropriate Test Statistics Involving Population MeanIdentifying Appropriate Test Statistics Involving Population Mean
Identifying Appropriate Test Statistics Involving Population MeanMYRABACSAFRA2
 
DBA Basics: Getting Started with Performance Tuning.pdf
DBA Basics: Getting Started with Performance Tuning.pdfDBA Basics: Getting Started with Performance Tuning.pdf
DBA Basics: Getting Started with Performance Tuning.pdfJohn Sterrett
 
Defining Constituents, Data Vizzes and Telling a Data Story
Defining Constituents, Data Vizzes and Telling a Data StoryDefining Constituents, Data Vizzes and Telling a Data Story
Defining Constituents, Data Vizzes and Telling a Data StoryJeremy Anderson
 
NO1 Certified Black Magic Specialist Expert Amil baba in Lahore Islamabad Raw...
NO1 Certified Black Magic Specialist Expert Amil baba in Lahore Islamabad Raw...NO1 Certified Black Magic Specialist Expert Amil baba in Lahore Islamabad Raw...
NO1 Certified Black Magic Specialist Expert Amil baba in Lahore Islamabad Raw...Amil Baba Dawood bangali
 
Call Us ➥97111√47426🤳Call Girls in Aerocity (Delhi NCR)
Call Us ➥97111√47426🤳Call Girls in Aerocity (Delhi NCR)Call Us ➥97111√47426🤳Call Girls in Aerocity (Delhi NCR)
Call Us ➥97111√47426🤳Call Girls in Aerocity (Delhi NCR)jennyeacort
 
ASML's Taxonomy Adventure by Daniel Canter
ASML's Taxonomy Adventure by Daniel CanterASML's Taxonomy Adventure by Daniel Canter
ASML's Taxonomy Adventure by Daniel Cantervoginip
 
9711147426✨Call In girls Gurgaon Sector 31. SCO 25 escort service
9711147426✨Call In girls Gurgaon Sector 31. SCO 25 escort service9711147426✨Call In girls Gurgaon Sector 31. SCO 25 escort service
9711147426✨Call In girls Gurgaon Sector 31. SCO 25 escort servicejennyeacort
 
RadioAdProWritingCinderellabyButleri.pdf
RadioAdProWritingCinderellabyButleri.pdfRadioAdProWritingCinderellabyButleri.pdf
RadioAdProWritingCinderellabyButleri.pdfgstagge
 
Predictive Analysis for Loan Default Presentation : Data Analysis Project PPT
Predictive Analysis for Loan Default  Presentation : Data Analysis Project PPTPredictive Analysis for Loan Default  Presentation : Data Analysis Project PPT
Predictive Analysis for Loan Default Presentation : Data Analysis Project PPTBoston Institute of Analytics
 
Semantic Shed - Squashing and Squeezing.pptx
Semantic Shed - Squashing and Squeezing.pptxSemantic Shed - Squashing and Squeezing.pptx
Semantic Shed - Squashing and Squeezing.pptxMike Bennett
 
Student Profile Sample report on improving academic performance by uniting gr...
Student Profile Sample report on improving academic performance by uniting gr...Student Profile Sample report on improving academic performance by uniting gr...
Student Profile Sample report on improving academic performance by uniting gr...Seán Kennedy
 
GA4 Without Cookies [Measure Camp AMS]
GA4 Without Cookies [Measure Camp AMS]GA4 Without Cookies [Measure Camp AMS]
GA4 Without Cookies [Measure Camp AMS]📊 Markus Baersch
 
办理学位证纽约大学毕业证(NYU毕业证书)原版一比一
办理学位证纽约大学毕业证(NYU毕业证书)原版一比一办理学位证纽约大学毕业证(NYU毕业证书)原版一比一
办理学位证纽约大学毕业证(NYU毕业证书)原版一比一fhwihughh
 
专业一比一美国俄亥俄大学毕业证成绩单pdf电子版制作修改
专业一比一美国俄亥俄大学毕业证成绩单pdf电子版制作修改专业一比一美国俄亥俄大学毕业证成绩单pdf电子版制作修改
专业一比一美国俄亥俄大学毕业证成绩单pdf电子版制作修改yuu sss
 
毕业文凭制作#回国入职#diploma#degree澳洲中央昆士兰大学毕业证成绩单pdf电子版制作修改#毕业文凭制作#回国入职#diploma#degree
毕业文凭制作#回国入职#diploma#degree澳洲中央昆士兰大学毕业证成绩单pdf电子版制作修改#毕业文凭制作#回国入职#diploma#degree毕业文凭制作#回国入职#diploma#degree澳洲中央昆士兰大学毕业证成绩单pdf电子版制作修改#毕业文凭制作#回国入职#diploma#degree
毕业文凭制作#回国入职#diploma#degree澳洲中央昆士兰大学毕业证成绩单pdf电子版制作修改#毕业文凭制作#回国入职#diploma#degreeyuu sss
 
Student profile product demonstration on grades, ability, well-being and mind...
Student profile product demonstration on grades, ability, well-being and mind...Student profile product demonstration on grades, ability, well-being and mind...
Student profile product demonstration on grades, ability, well-being and mind...Seán Kennedy
 
While-For-loop in python used in college
While-For-loop in python used in collegeWhile-For-loop in python used in college
While-For-loop in python used in collegessuser7a7cd61
 

Recently uploaded (20)

Indian Call Girls in Abu Dhabi O5286O24O8 Call Girls in Abu Dhabi By Independ...
Indian Call Girls in Abu Dhabi O5286O24O8 Call Girls in Abu Dhabi By Independ...Indian Call Girls in Abu Dhabi O5286O24O8 Call Girls in Abu Dhabi By Independ...
Indian Call Girls in Abu Dhabi O5286O24O8 Call Girls in Abu Dhabi By Independ...
 
办理学位证中佛罗里达大学毕业证,UCF成绩单原版一比一
办理学位证中佛罗里达大学毕业证,UCF成绩单原版一比一办理学位证中佛罗里达大学毕业证,UCF成绩单原版一比一
办理学位证中佛罗里达大学毕业证,UCF成绩单原版一比一
 
Effects of Smartphone Addiction on the Academic Performances of Grades 9 to 1...
Effects of Smartphone Addiction on the Academic Performances of Grades 9 to 1...Effects of Smartphone Addiction on the Academic Performances of Grades 9 to 1...
Effects of Smartphone Addiction on the Academic Performances of Grades 9 to 1...
 
Identifying Appropriate Test Statistics Involving Population Mean
Identifying Appropriate Test Statistics Involving Population MeanIdentifying Appropriate Test Statistics Involving Population Mean
Identifying Appropriate Test Statistics Involving Population Mean
 
DBA Basics: Getting Started with Performance Tuning.pdf
DBA Basics: Getting Started with Performance Tuning.pdfDBA Basics: Getting Started with Performance Tuning.pdf
DBA Basics: Getting Started with Performance Tuning.pdf
 
Defining Constituents, Data Vizzes and Telling a Data Story
Defining Constituents, Data Vizzes and Telling a Data StoryDefining Constituents, Data Vizzes and Telling a Data Story
Defining Constituents, Data Vizzes and Telling a Data Story
 
NO1 Certified Black Magic Specialist Expert Amil baba in Lahore Islamabad Raw...
NO1 Certified Black Magic Specialist Expert Amil baba in Lahore Islamabad Raw...NO1 Certified Black Magic Specialist Expert Amil baba in Lahore Islamabad Raw...
NO1 Certified Black Magic Specialist Expert Amil baba in Lahore Islamabad Raw...
 
Call Us ➥97111√47426🤳Call Girls in Aerocity (Delhi NCR)
Call Us ➥97111√47426🤳Call Girls in Aerocity (Delhi NCR)Call Us ➥97111√47426🤳Call Girls in Aerocity (Delhi NCR)
Call Us ➥97111√47426🤳Call Girls in Aerocity (Delhi NCR)
 
ASML's Taxonomy Adventure by Daniel Canter
ASML's Taxonomy Adventure by Daniel CanterASML's Taxonomy Adventure by Daniel Canter
ASML's Taxonomy Adventure by Daniel Canter
 
9711147426✨Call In girls Gurgaon Sector 31. SCO 25 escort service
9711147426✨Call In girls Gurgaon Sector 31. SCO 25 escort service9711147426✨Call In girls Gurgaon Sector 31. SCO 25 escort service
9711147426✨Call In girls Gurgaon Sector 31. SCO 25 escort service
 
RadioAdProWritingCinderellabyButleri.pdf
RadioAdProWritingCinderellabyButleri.pdfRadioAdProWritingCinderellabyButleri.pdf
RadioAdProWritingCinderellabyButleri.pdf
 
Predictive Analysis for Loan Default Presentation : Data Analysis Project PPT
Predictive Analysis for Loan Default  Presentation : Data Analysis Project PPTPredictive Analysis for Loan Default  Presentation : Data Analysis Project PPT
Predictive Analysis for Loan Default Presentation : Data Analysis Project PPT
 
Semantic Shed - Squashing and Squeezing.pptx
Semantic Shed - Squashing and Squeezing.pptxSemantic Shed - Squashing and Squeezing.pptx
Semantic Shed - Squashing and Squeezing.pptx
 
Student Profile Sample report on improving academic performance by uniting gr...
Student Profile Sample report on improving academic performance by uniting gr...Student Profile Sample report on improving academic performance by uniting gr...
Student Profile Sample report on improving academic performance by uniting gr...
 
GA4 Without Cookies [Measure Camp AMS]
GA4 Without Cookies [Measure Camp AMS]GA4 Without Cookies [Measure Camp AMS]
GA4 Without Cookies [Measure Camp AMS]
 
办理学位证纽约大学毕业证(NYU毕业证书)原版一比一
办理学位证纽约大学毕业证(NYU毕业证书)原版一比一办理学位证纽约大学毕业证(NYU毕业证书)原版一比一
办理学位证纽约大学毕业证(NYU毕业证书)原版一比一
 
专业一比一美国俄亥俄大学毕业证成绩单pdf电子版制作修改
专业一比一美国俄亥俄大学毕业证成绩单pdf电子版制作修改专业一比一美国俄亥俄大学毕业证成绩单pdf电子版制作修改
专业一比一美国俄亥俄大学毕业证成绩单pdf电子版制作修改
 
毕业文凭制作#回国入职#diploma#degree澳洲中央昆士兰大学毕业证成绩单pdf电子版制作修改#毕业文凭制作#回国入职#diploma#degree
毕业文凭制作#回国入职#diploma#degree澳洲中央昆士兰大学毕业证成绩单pdf电子版制作修改#毕业文凭制作#回国入职#diploma#degree毕业文凭制作#回国入职#diploma#degree澳洲中央昆士兰大学毕业证成绩单pdf电子版制作修改#毕业文凭制作#回国入职#diploma#degree
毕业文凭制作#回国入职#diploma#degree澳洲中央昆士兰大学毕业证成绩单pdf电子版制作修改#毕业文凭制作#回国入职#diploma#degree
 
Student profile product demonstration on grades, ability, well-being and mind...
Student profile product demonstration on grades, ability, well-being and mind...Student profile product demonstration on grades, ability, well-being and mind...
Student profile product demonstration on grades, ability, well-being and mind...
 
While-For-loop in python used in college
While-For-loop in python used in collegeWhile-For-loop in python used in college
While-For-loop in python used in college
 

Indexing Strategies for Optimal Database Performance

  • 2. “An index is an optional structure, associated with a table or table cluster, that can sometimes speed data access.”
  • 3. B-TREE INDEXES • Most common type of index • Data is ordered within the index • Consists of branches and leaves
  • 5. B-TREE INDEXES • Options include • Unique • Descending • Reverse Key • Index Organized Tables • Composite, Covering, Concatenated • Compressed
  • 6. REVERSE KEY INDEXES • Creates a “mirror image” of the key • UTOUG would become GUOTU • Used to spread block splits and avoid hot blocks in RAC environments • No index range scans • Lots of conflicting information • Test extensively, and use with caution
  • 7. REVERSE KEY INDEXES • Two implementations: • last_updated_date in a customer order table • Sequentially updated primary key
  • 8. REVERSE KEY INDEXES • Things to watch for: • Increase in db sequential read wait events • Backup time increase • Space use increase
  • 9. INDEX ORGANIZED TABLES • Stores data and index in the same segment • Must have a primary key • Data is ordered • Can have secondary indexes • Useful for tables that are fully accessed • Overflow for less-used data
  • 10. COMPOSITE INDEXES • Sometimes known as covering or concatenated • Consist of more than one column • Leading column is important
  • 11. COMPOSITE INDEXES create index test_i1 on test(col1); create index test_i2 on test(col1, col2);
  • 12. COMPOSITE INDEXES • Choosing a leading column • High cardinality? • Low cardinality? • Most frequently accessed
  • 13. • The Poor-Man’s IOT • Use to improve performance of select by reducing I/O COVERING INDEXES
  • 14.  SELECT price_id ,         price       FROM dcs_price     WHERE version_id       = :1       AND price_id           = :2; ------------------------------------------------------------------------------------------- | Id  | Operation                   | Name        | Rows  | Bytes | Cost (%CPU)| Time     | ------------------------------------------------------------------------------------------- |   0 | SELECT STATEMENT            |             |     1 |    29 |     5   (0)| 00:00:01 | |*  1 |  TABLE ACCESS BY INDEX ROWID| DCS_PRICE   |     1 |    29 |     5   (0)| 00:00:01 | |*  2 |   INDEX RANGE SCAN          | DCS_PRICE_P |     2 |       |     3   (0)| 00:00:01 | -------------------------------------------------------------------------------------------
  • 15. create unique index dcs_price_i3       on dcs_price ( price_id , version_id , price); ----------------------------------------------------------------------------------- | Id  | Operation        | Name           | Rows  | Bytes | Cost (%CPU)| Time     | ----------------------------------------------------------------------------------- |   0 | SELECT STATEMENT |                |     1 |    22 |     2   (0)| 00:00:01 | |*  1 |  INDEX RANGE SCAN| DCS_PRICE_I03 |     1 |    22 |     2   (0)| 00:00:01 | -----------------------------------------------------------------------------------
  • 16. COMPRESSED KEY INDEXES • Leading columns have low cardinality • Save space • Improve performance
  • 17. BITMAP INDEXES • Index on low cardinality data • Take up little space • Bitmap join • Typically found in data warehouse environments
  • 18. FUNCTION BASED, INDEXEDVIRTUAL • Index on a database function (predefined, user written) • Allows index lookups when a function is used • Both store the derived value in the index
  • 19. INVISIBLE INDEXES • Create or modify an index to be invisible • Invisible to the optimizer • Still maintained by the database • Better, more reliable option than MONITORING USAGE • Must set optimizer_use_invisible_indexes=TRUE
  • 20. VIRTUAL INDEXES • Only visible to the optimizer • Used for evaluating an indexes usefulness
  • 21. VIRTUAL INDEXES SQL> create table test (col1 integer); Table created. SQL> create index test_i1 on test(col1); Index created. SQL> create index test_i2 on test(col1); create index test_i2 on test(col1) * ERROR at line 1: ORA-01408: such column list already indexed
  • 22. VIRTUAL INDEXES SQL> create index test_i2 on test(col1) nosegment; Index created. SQL> select table_name, index_name, column_name from user_ind_columns where table_name = 'TEST'; TABLE_NAME INDEX_NAME COLUMN_NAME ------------------------------ ------------------------------ -------------------- TEST TEST_I1 COL1 TEST TEST_I2 COL1
  • 23. CLUSTER INDEXES • B-Tree Cluster Index • Hash Cluster Index • Hash clusters can exist on a single table
  • 24. PARTITIONED INDEXES • Global Partitioned • Crosses partitions • Exists on whole table • Local Partitioned • Unique to each partition • Watch out for non-partitioned indexes on partitions
  • 25. PARTITIONED INDEXES • Locally partitioned indexes • Isolate maintenance operations to a single partition • Mark unusable/invisible independently • Separate partitions into different tablespaces • Prefixed, non-prefixed • Unique indexes must include partition key • Can only exist on partitioned tables
  • 26. PARTITIONED INDEXES • Globally partitioned indexes • Can exist on non-partitioned tables • Can be either range or hash based • Partition maintenance can render the index unusable • Global indexes on partitioned tables must lead with the partition key
  • 27. PARTITIONED INDEXES Local partition Partition index unusable Partition index unusable Partitions involved unusable Partition index unusable No effect on index No effect on index Global or non-partition Entire index unusable Entire index unusable Entire index unusable Entire index unusable Entire index unusable Entire index unusable Operation Split Move Merge Exchange Truncate Drop
  • 28. WHAT TO INDEX • Primary keys • Unique keys • Foreign keys • Columns frequently used in where, distinct, and order by clauses • Columns often queried together
  • 29. Index all that should be, and no more.
  • 30. If in doubt, b-tree is probably safest.
  • 31. KEY CONSIDERATIONS Create primary and unique keys within a create table or build the indexes and constraints separately? The create table method is easier, but: • Indexes don’t persist • May break GoldenGate, replication
  • 32. create table test1 ( col1 integer); create unique index test1_p on test1(col1); alter table test1 add constraint test1_p primary key (col1) using index test1_p; create table test2 ( col1 integer primary key); -or- create table test2 ( col1 integer, constraint test2_p primary key (col1));
  • 33. select table_name, index_name from dba_indexes where table_name like 'TEST%'; TEST2 SYS_C0015135 TEST1 TEST1_P
  • 34. alter table test1 drop constraint test1_p; alter table test2 drop constraint SYS_C0015135; select table_name, index_name from dba_indexes where table_name like 'TEST%'; TEST1 TEST1_P
  • 35. • Pick a convention and stick to it! • tablename_p • tablename_un • tablename_in • tablename_fn • tablename_bn • ...etc NAMING CONVENTION
  • 36. -------------------------------------------------------------------------------------------------------- | Id | Operation" " " "" " " | Name" " " | Rows | Bytes| Cost (%CPU)| Time " | -------------------------------------------------------------------------------------------------------- | 0 | SELECT STATEMENT"" "" " " |" " " " | 30| 4230| 560 (1)| 00:00:07| | 1 | SORT ORDER BY" " " "" " |" " " " | 30| 4230| 560 (1)| 00:00:07| | 2 | NESTED LOOPS" " " "" " |" " " " | 30| 4230| 559 (1)| 00:00:07| | 3 | NESTED LOOPS "" "" " " |" " " " | 30| 3630| 552 (1)| 00:00:07| | 4 | NESTED LOOPS"" "" " " |" " " " | 30| 2790| 544 (1)| 00:00:07| | 5 | MERGE JOIN "" "" " " |" " " " | 30| 1290| 537 (1)| 00:00:07| |* 6 | TABLE ACCESS BY INDEX ROWID " | TICKET_STATUSES" | 7| 42| 1 (0)| 00:00:01| |* 7 | INDEX FULL SCAN" " "" | SYS_C0107546 | 10| | 1 (0)| 00:00:01| |* 8 | SORT JOIN "" "" " " |" " " " | 35| 1295| 536 (1)| 00:00:07| |* 9 | TABLE ACCESS BY INDEX ROWID " | TICKETS"" " | 35| 1295| 535 (1)| 00:00:07| | 10 | " BITMAP CONVERSION TO ROWIDS " " |" " " " | | |" " |" " | | 11 | " BITMAP AND" " "" " " |" " " " | | |" " " |" " | | 12 | " BITMAP MINUS" " "" " |" " " " | | |" " | " " | |* 13 | " BITMAP INDEX SINGLE VALUE" " | TICKETS1 " | | |" " | " " | |* 14 | " BITMAP INDEX SINGLE VALUE" " | IDX_TICKETS_I01 "| | |" " " | " " | |* 15 | " BITMAP INDEX SINGLE VALUE " " | TICKETS_INDEX | | |" " " |" " | | 16 | TABLE ACCESS BY INDEX ROWID " | PANELS"" " | 1| 50| 1 (0)| 00:00:01| |* 17 | INDEX UNIQUE SCAN " "" " | SYS_C0367234 " | 1| | 1 (0)| 00:00:01| | 18 | TABLE ACCESS BY INDEX ROWID " | USERS" " " | 1| 28| 1 (0)| 00:00:01| |* 19 | INDEX UNIQUE SCAN" " "" | SYS_C0038942" | 1| | 1 (0)| 00:00:01| | 20 | TABLE ACCESS BY INDEX ROWID" "" | CUSTOMERS " " | 1| 20| 1 (0)| 00:00:01| |* 21 | INDEX UNIQUE SCAN"" "" " | SYS_C8712300" | 1| | 1 (0)| 00:00:01| --------------------------------------------------------------------------------------------------------
  • 37. STORAGE • Consider separating table and index tablespaces • Specify suitable storage parameters • PCTFREE is meaningless in indexes • logging/nologging • Extent and block size can be defined • Manage backups • Manage physical storage
  • 38. • Index reorganization options • alter index rebuild • alter index coalesce • alter index shrink space (compact) MAINTENANCE
  • 39. • Use DBMS_STATS • Defaults are usually best: exec dbms_stats.set_global_prefs(‘METHOD_OPT’, ‘FOR ALL COLUMNS SIZE AUTO’); exec dbms_stats.reset_global_pref_defaults; • CASCADE=TRUE structureddata.org/2008/10/14/dbms_stats-method_opt-and-for-all-indexed-columns/ GENERATING STATISTICS
  • 40. • Introduced in 11g • Allows you to create column groups • Determines a relationship among potentially skewed data dbms_stats.create_extended_stats( ‘APP’, ‘CUSTOMERS’, ‘(BIRTHDATE, BIRTHSTONE)’); EXTENDED STATISTICS