SlideShare una empresa de Scribd logo
1 de 20
Managing Indexes
Objectives
After completing this lesson, you should be able to
do the following:
• List the different types of indexes and their uses
• Create B-tree and bitmap indexes
• Reorganize indexes
• Drop indexes
• Get index information from the data dictionary
Classification of Indexes
• Logical
– Single column or concatenated
– Unique or nonunique
– Function-based
• Physical
– Partitioned or nonpartitioned
– B-tree
– Normal or reverse key
– Bitmap
B-Tree Index
Index entry header
Key column length
Key column value
ROWID
Root
Branch
Leaf
Index entry
KEY ROWID
ID (BLOCK# ROW# FILE#)
----- -------------------
1257 0000000F.0002.0001
2877 0000000F.0006.0001
4567 0000000F.0004.0001
6657 0000000F.0003.0001
8967 0000000F.0005.0001
9637 0000000F.0001.0001
9947 0000000F.0000.0001
... ...
... ...
Reverse Key Index
Index on EMPLOYEE (ID) EMPLOYEE table
ID FIRST_NAME JOB
----- ---------- --------
7499 ALLEN SALESMAN
7369 SMITH CLERK
7521 WARD SALESMAN
7566 JONES MANAGER
7654 MARTIN SALESMAN
7698 BLAKE MANAGER
7782 CLARK MANAGER
… ... ... ...
... ... ... ...
Creating Function-Based Indexes
• Dramatically improves query performance
• Queries using expressions can use the index
CREATE INDEX summit.item_quantity_to_deliver_idx
ON summit.item(quantity - quantity_shipped);
SELECT ord_id, item_id
FROM ITEM
WHERE (quantity - quantity_shipped) > 0;
Bitmap Index
<Blue, 10.0.3, 12.8.3, 1000100100010010100>
<Green, 10.0.3, 12.8.3, 0001010000100100000>
<Red, 10.0.3, 12.8.3, 0100000011000001001>
<Yellow, 10.0.3, 12.8.3, 0010001000001000010>
key
start
ROWID
end
ROWID bitmap
Table
Index
Block 10
Block 11
Block 12
File 3
Comparing B-Tree and
Bitmap Indexes
B-tree
Suitable for high-cardinality
columns
Updates on keys relatively
inexpensive
Inefficient for queries
using OR predicates
Useful for OLTP
Bitmap
Suitable for low-cardinality
columns
Updates to key columns very
expensive
Efficient for queries
using OR predicates
Useful for data warehousing
Creating Normal B-Tree Indexes
CREATE INDEX summit.employee_last_name_idx
ON summit.employee(last_name)
PCTFREE 30
STORAGE(INITIAL 200K NEXT 200K
PCTINCREASE 0 MAXEXTENTS 50)
TABLESPACE indx;
Creating Indexes: Guidelines
• Balance query and DML needs
• Place in separate tablespace
• Use uniform extent sizes: Multiples of five blocks
or MINIMUM EXTENT size for tablespace
• Consider NOLOGGING for large indexes
• Set high PCTFREE if new key values are likely to
be within the current range
Creating Reverse Key Indexes
CREATE UNIQUE INDEX summit.orders_id_idx
ON summit.orders(id) REVERSE
PCTFREE 30
STORAGE(INITIAL 200K NEXT 200K
PCTINCREASE 0 MAXEXTENTS 50)
TABLESPACE indx;
Creating Bitmap Indexes
Use the parameter CREATE_BITMAP_AREA_SIZE to
specify the amount of memory allocated for bitmap
creation.
CREATE BITMAP INDEX orders_region_id_idx
ON summit.orders(region_id)
PCTFREE 30
STORAGE(INITIAL 200K NEXT 200K
PCTINCREASE 0 MAXEXTENTS 50)
TABLESPACE indx;
Changing Storage Parameters for
Indexes
ALTER INDEX summit.employee_last_name_idx
STORAGE(NEXT 400K
MAXEXTENTS 100);
Allocating and Deallocating Index
Space
ALTER INDEX summit.orders_region_id_idx
ALLOCATE EXTENT (SIZE 200K
DATAFILE ‘/DISK6/indx01.dbf’);
ALTER INDEX summit.orders_id_idx
DEALLOCATE UNUSED;
Rebuilding Indexes
Use the ALTER INDEX command to:
• Move an index to a different tablespace
• Improve space utilization by removing deleted
entries
• Change a reverse key index to a normal B-tree
index and vice versa
ALTER INDEX summit.orders_region_id_idx REBUILD
TABLESPACE indx02;
Online Rebuild of Indexes
Rebuilding indexes can be done with minimal table
locking.
ALTER INDEX summit.orders_id_idx REBUILD ONLINE;
Coalescing Indexes
Before coalescing After coalescing
ALTER INDEX summit.orders_id_idx COALESCE;
Dropping Indexes
• Drop and re-create an index before bulk loads.
• Drop indexes that are infrequently needed and build
them when necessary.
• Drop and re-create invalid indexes.
DROP INDEX summit.deptartment_name_idx;
Obtaining Index Information
DBA_INDEXES
OWNER
INDEX_NAME
INDEX_TYPE
TABLE_OWNER
TABLE_NAME
UNIQUENESS
TABLESPACE_NAME
LOGGING
STATUS
DBA_IND_COLUMNS
INDEX_OWNER
INDEX_NAME
TABLE_OWNER
TABLE_NAME
COLUMN_NAME
COLUMN_POSITION
COLUMN_LENGTH
Summary
In this lesson, you should have learned how to:
• Create different types of indexes
• Reorganize indexes
• Drop indexes
• Get index information from the data dictionary

Más contenido relacionado

Similar a Clase 12 manejo indices modificada

Star schema my sql
Star schema   my sqlStar schema   my sql
Star schema my sqldeathsubte
 
Covering indexes
Covering indexesCovering indexes
Covering indexesMYXPLAIN
 
DB2UDB_the_Basics Day2
DB2UDB_the_Basics Day2DB2UDB_the_Basics Day2
DB2UDB_the_Basics Day2Pranav Prakash
 
Data Warehouse Logical Design using Mysql
Data Warehouse Logical Design using MysqlData Warehouse Logical Design using Mysql
Data Warehouse Logical Design using MysqlHAFIZ Islam
 
Dan Hotka's Top 10 Oracle 12c New Features
Dan Hotka's Top 10 Oracle 12c New FeaturesDan Hotka's Top 10 Oracle 12c New Features
Dan Hotka's Top 10 Oracle 12c New FeaturesEmbarcadero Technologies
 
Implementing Tables and Views.pptx
Implementing Tables and Views.pptxImplementing Tables and Views.pptx
Implementing Tables and Views.pptxLuisManuelUrbinaAmad
 
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
 
Oracle Database InMemory
Oracle Database InMemoryOracle Database InMemory
Oracle Database InMemoryJorge Barba
 
Performance Tuning Oracle's BI Applications
Performance Tuning Oracle's BI ApplicationsPerformance Tuning Oracle's BI Applications
Performance Tuning Oracle's BI ApplicationsKPI Partners
 
Transform Financial Reporting Using Master Row Sets in Oracle E-Business Suite
Transform Financial Reporting Using Master Row Sets in Oracle E-Business SuiteTransform Financial Reporting Using Master Row Sets in Oracle E-Business Suite
Transform Financial Reporting Using Master Row Sets in Oracle E-Business Suiteeprentise
 
Less07 schema
Less07 schemaLess07 schema
Less07 schemaImran Ali
 
Improve speed &amp; performance of informix 11.xx part 1
Improve speed &amp; performance of informix 11.xx   part 1Improve speed &amp; performance of informix 11.xx   part 1
Improve speed &amp; performance of informix 11.xx part 1am_prasanna
 
How mysql choose the execution plan
How mysql choose the execution planHow mysql choose the execution plan
How mysql choose the execution plan辛鹤 李
 
Advanced PL/SQL Optimizing for Better Performance 2016
Advanced PL/SQL Optimizing for Better Performance 2016Advanced PL/SQL Optimizing for Better Performance 2016
Advanced PL/SQL Optimizing for Better Performance 2016Zohar Elkayam
 
15 Ways to Kill Your Mysql Application Performance
15 Ways to Kill Your Mysql Application Performance15 Ways to Kill Your Mysql Application Performance
15 Ways to Kill Your Mysql Application Performanceguest9912e5
 
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
 
Clase 11 manejo tablas modificada
Clase 11 manejo tablas   modificadaClase 11 manejo tablas   modificada
Clase 11 manejo tablas modificadaTitiushko Jazz
 
Clase 11 manejo tablas modificada
Clase 11 manejo tablas   modificadaClase 11 manejo tablas   modificada
Clase 11 manejo tablas modificadaTitiushko Jazz
 

Similar a Clase 12 manejo indices modificada (20)

Star schema my sql
Star schema   my sqlStar schema   my sql
Star schema my sql
 
Sql server T-sql basics ppt-3
Sql server T-sql basics  ppt-3Sql server T-sql basics  ppt-3
Sql server T-sql basics ppt-3
 
Covering indexes
Covering indexesCovering indexes
Covering indexes
 
DB2UDB_the_Basics Day2
DB2UDB_the_Basics Day2DB2UDB_the_Basics Day2
DB2UDB_the_Basics Day2
 
Data Warehouse Logical Design using Mysql
Data Warehouse Logical Design using MysqlData Warehouse Logical Design using Mysql
Data Warehouse Logical Design using Mysql
 
Dan Hotka's Top 10 Oracle 12c New Features
Dan Hotka's Top 10 Oracle 12c New FeaturesDan Hotka's Top 10 Oracle 12c New Features
Dan Hotka's Top 10 Oracle 12c New Features
 
Implementing Tables and Views.pptx
Implementing Tables and Views.pptxImplementing Tables and Views.pptx
Implementing Tables and Views.pptx
 
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
 
Rdbms day3
Rdbms day3Rdbms day3
Rdbms day3
 
Oracle Database InMemory
Oracle Database InMemoryOracle Database InMemory
Oracle Database InMemory
 
Performance Tuning Oracle's BI Applications
Performance Tuning Oracle's BI ApplicationsPerformance Tuning Oracle's BI Applications
Performance Tuning Oracle's BI Applications
 
Transform Financial Reporting Using Master Row Sets in Oracle E-Business Suite
Transform Financial Reporting Using Master Row Sets in Oracle E-Business SuiteTransform Financial Reporting Using Master Row Sets in Oracle E-Business Suite
Transform Financial Reporting Using Master Row Sets in Oracle E-Business Suite
 
Less07 schema
Less07 schemaLess07 schema
Less07 schema
 
Improve speed &amp; performance of informix 11.xx part 1
Improve speed &amp; performance of informix 11.xx   part 1Improve speed &amp; performance of informix 11.xx   part 1
Improve speed &amp; performance of informix 11.xx part 1
 
How mysql choose the execution plan
How mysql choose the execution planHow mysql choose the execution plan
How mysql choose the execution plan
 
Advanced PL/SQL Optimizing for Better Performance 2016
Advanced PL/SQL Optimizing for Better Performance 2016Advanced PL/SQL Optimizing for Better Performance 2016
Advanced PL/SQL Optimizing for Better Performance 2016
 
15 Ways to Kill Your Mysql Application Performance
15 Ways to Kill Your Mysql Application Performance15 Ways to Kill Your Mysql Application Performance
15 Ways to Kill Your Mysql Application Performance
 
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
 
Clase 11 manejo tablas modificada
Clase 11 manejo tablas   modificadaClase 11 manejo tablas   modificada
Clase 11 manejo tablas modificada
 
Clase 11 manejo tablas modificada
Clase 11 manejo tablas   modificadaClase 11 manejo tablas   modificada
Clase 11 manejo tablas modificada
 

Más de Titiushko Jazz

Unidad vii esp parte 3 clase de inteligencia de negocios (datawarehouse)
Unidad vii esp parte 3 clase de inteligencia de negocios (datawarehouse)Unidad vii esp parte 3 clase de inteligencia de negocios (datawarehouse)
Unidad vii esp parte 3 clase de inteligencia de negocios (datawarehouse)Titiushko Jazz
 
Unidad vii esp parte 3 clase de datawarehouse ( ing. doño)
Unidad vii esp parte 3 clase de datawarehouse ( ing. doño)Unidad vii esp parte 3 clase de datawarehouse ( ing. doño)
Unidad vii esp parte 3 clase de datawarehouse ( ing. doño)Titiushko Jazz
 
Unidad vii esp parte 2 introduccion a data warehouse y datamining
Unidad vii esp parte 2 introduccion a data warehouse y dataminingUnidad vii esp parte 2 introduccion a data warehouse y datamining
Unidad vii esp parte 2 introduccion a data warehouse y dataminingTitiushko Jazz
 
Unidad vi esp parte 2 procesimientos en plsql y transact sql
Unidad vi esp parte 2 procesimientos en plsql y transact sqlUnidad vi esp parte 2 procesimientos en plsql y transact sql
Unidad vi esp parte 2 procesimientos en plsql y transact sqlTitiushko Jazz
 
Tarea pronosticos eily
Tarea pronosticos eilyTarea pronosticos eily
Tarea pronosticos eilyTitiushko Jazz
 
Proyecto teórico práctico
Proyecto teórico prácticoProyecto teórico práctico
Proyecto teórico prácticoTitiushko Jazz
 

Más de Titiushko Jazz (20)

Unidad vii esp parte 3 clase de inteligencia de negocios (datawarehouse)
Unidad vii esp parte 3 clase de inteligencia de negocios (datawarehouse)Unidad vii esp parte 3 clase de inteligencia de negocios (datawarehouse)
Unidad vii esp parte 3 clase de inteligencia de negocios (datawarehouse)
 
Unidad vii esp parte 3 clase de datawarehouse ( ing. doño)
Unidad vii esp parte 3 clase de datawarehouse ( ing. doño)Unidad vii esp parte 3 clase de datawarehouse ( ing. doño)
Unidad vii esp parte 3 clase de datawarehouse ( ing. doño)
 
Unidad vii esp parte 2 introduccion a data warehouse y datamining
Unidad vii esp parte 2 introduccion a data warehouse y dataminingUnidad vii esp parte 2 introduccion a data warehouse y datamining
Unidad vii esp parte 2 introduccion a data warehouse y datamining
 
Unidad vi esp parte 2 procesimientos en plsql y transact sql
Unidad vi esp parte 2 procesimientos en plsql y transact sqlUnidad vi esp parte 2 procesimientos en plsql y transact sql
Unidad vi esp parte 2 procesimientos en plsql y transact sql
 
Unidad ii esp parte 2
Unidad ii esp parte 2Unidad ii esp parte 2
Unidad ii esp parte 2
 
Unidad ii esp parte 1
Unidad ii esp parte 1Unidad ii esp parte 1
Unidad ii esp parte 1
 
Unidad i esp parte 2
Unidad i esp parte 2Unidad i esp parte 2
Unidad i esp parte 2
 
Unidad i esp parte 1
Unidad i esp parte 1Unidad i esp parte 1
Unidad i esp parte 1
 
Tarea pronosticos eily
Tarea pronosticos eilyTarea pronosticos eily
Tarea pronosticos eily
 
Sociedades limitadas
Sociedades limitadasSociedades limitadas
Sociedades limitadas
 
Rhu
RhuRhu
Rhu
 
Qué es un proyecto
Qué es un proyectoQué es un proyecto
Qué es un proyecto
 
Proyecto teórico práctico
Proyecto teórico prácticoProyecto teórico práctico
Proyecto teórico práctico
 
Presentacion1630
Presentacion1630Presentacion1630
Presentacion1630
 
Presentacion1410
Presentacion1410Presentacion1410
Presentacion1410
 
Presentacion1310
Presentacion1310Presentacion1310
Presentacion1310
 
Presentacion1210
Presentacion1210Presentacion1210
Presentacion1210
 
Presentacion1220
Presentacion1220Presentacion1220
Presentacion1220
 
Presentacion1001
Presentacion1001Presentacion1001
Presentacion1001
 
Presentacion810
Presentacion810Presentacion810
Presentacion810
 

Clase 12 manejo indices modificada

  • 2. Objectives After completing this lesson, you should be able to do the following: • List the different types of indexes and their uses • Create B-tree and bitmap indexes • Reorganize indexes • Drop indexes • Get index information from the data dictionary
  • 3. Classification of Indexes • Logical – Single column or concatenated – Unique or nonunique – Function-based • Physical – Partitioned or nonpartitioned – B-tree – Normal or reverse key – Bitmap
  • 4. B-Tree Index Index entry header Key column length Key column value ROWID Root Branch Leaf Index entry
  • 5. KEY ROWID ID (BLOCK# ROW# FILE#) ----- ------------------- 1257 0000000F.0002.0001 2877 0000000F.0006.0001 4567 0000000F.0004.0001 6657 0000000F.0003.0001 8967 0000000F.0005.0001 9637 0000000F.0001.0001 9947 0000000F.0000.0001 ... ... ... ... Reverse Key Index Index on EMPLOYEE (ID) EMPLOYEE table ID FIRST_NAME JOB ----- ---------- -------- 7499 ALLEN SALESMAN 7369 SMITH CLERK 7521 WARD SALESMAN 7566 JONES MANAGER 7654 MARTIN SALESMAN 7698 BLAKE MANAGER 7782 CLARK MANAGER … ... ... ... ... ... ... ...
  • 6. Creating Function-Based Indexes • Dramatically improves query performance • Queries using expressions can use the index CREATE INDEX summit.item_quantity_to_deliver_idx ON summit.item(quantity - quantity_shipped); SELECT ord_id, item_id FROM ITEM WHERE (quantity - quantity_shipped) > 0;
  • 7. Bitmap Index <Blue, 10.0.3, 12.8.3, 1000100100010010100> <Green, 10.0.3, 12.8.3, 0001010000100100000> <Red, 10.0.3, 12.8.3, 0100000011000001001> <Yellow, 10.0.3, 12.8.3, 0010001000001000010> key start ROWID end ROWID bitmap Table Index Block 10 Block 11 Block 12 File 3
  • 8. Comparing B-Tree and Bitmap Indexes B-tree Suitable for high-cardinality columns Updates on keys relatively inexpensive Inefficient for queries using OR predicates Useful for OLTP Bitmap Suitable for low-cardinality columns Updates to key columns very expensive Efficient for queries using OR predicates Useful for data warehousing
  • 9. Creating Normal B-Tree Indexes CREATE INDEX summit.employee_last_name_idx ON summit.employee(last_name) PCTFREE 30 STORAGE(INITIAL 200K NEXT 200K PCTINCREASE 0 MAXEXTENTS 50) TABLESPACE indx;
  • 10. Creating Indexes: Guidelines • Balance query and DML needs • Place in separate tablespace • Use uniform extent sizes: Multiples of five blocks or MINIMUM EXTENT size for tablespace • Consider NOLOGGING for large indexes • Set high PCTFREE if new key values are likely to be within the current range
  • 11. Creating Reverse Key Indexes CREATE UNIQUE INDEX summit.orders_id_idx ON summit.orders(id) REVERSE PCTFREE 30 STORAGE(INITIAL 200K NEXT 200K PCTINCREASE 0 MAXEXTENTS 50) TABLESPACE indx;
  • 12. Creating Bitmap Indexes Use the parameter CREATE_BITMAP_AREA_SIZE to specify the amount of memory allocated for bitmap creation. CREATE BITMAP INDEX orders_region_id_idx ON summit.orders(region_id) PCTFREE 30 STORAGE(INITIAL 200K NEXT 200K PCTINCREASE 0 MAXEXTENTS 50) TABLESPACE indx;
  • 13. Changing Storage Parameters for Indexes ALTER INDEX summit.employee_last_name_idx STORAGE(NEXT 400K MAXEXTENTS 100);
  • 14. Allocating and Deallocating Index Space ALTER INDEX summit.orders_region_id_idx ALLOCATE EXTENT (SIZE 200K DATAFILE ‘/DISK6/indx01.dbf’); ALTER INDEX summit.orders_id_idx DEALLOCATE UNUSED;
  • 15. Rebuilding Indexes Use the ALTER INDEX command to: • Move an index to a different tablespace • Improve space utilization by removing deleted entries • Change a reverse key index to a normal B-tree index and vice versa ALTER INDEX summit.orders_region_id_idx REBUILD TABLESPACE indx02;
  • 16. Online Rebuild of Indexes Rebuilding indexes can be done with minimal table locking. ALTER INDEX summit.orders_id_idx REBUILD ONLINE;
  • 17. Coalescing Indexes Before coalescing After coalescing ALTER INDEX summit.orders_id_idx COALESCE;
  • 18. Dropping Indexes • Drop and re-create an index before bulk loads. • Drop indexes that are infrequently needed and build them when necessary. • Drop and re-create invalid indexes. DROP INDEX summit.deptartment_name_idx;
  • 20. Summary In this lesson, you should have learned how to: • Create different types of indexes • Reorganize indexes • Drop indexes • Get index information from the data dictionary