Oracle9i Database Administrator: Implementation and Administration 1 Chapter 9 Index Management.

Slides:



Advertisements
Similar presentations
Tuning: overview Rewrite SQL (Leccotech)Leccotech Create Index Redefine Main memory structures (SGA in Oracle) Change the Block Size Materialized Views,
Advertisements

Oracle 10g Database Administrator: Implementation and Administration Chapter 8 Advanced Table Management.
Basic Storage Concepts and Settings
12 Copyright © Oracle Corporation, All rights reserved. Managing Indexes.
Semantec Ltd. Oracle Performance Tuning Boyan Pavlov Indexes Indexes.
Working with SQL Server Database Objects
Physical Database Design CIT alternate keys - named constraints - indexes.
IS 4420 Database Fundamentals Chapter 6: Physical Database Design and Performance Leon Chen.
Harvard University Oracle Database Administration Session 5 Data Storage.
Database Systems: Design, Implementation, and Management Eighth Edition Chapter 11 Database Performance Tuning and Query Optimization.
Introduction to Structured Query Language (SQL)
Data Integrity Constraints
Chapter 8 Physical Database Design. McGraw-Hill/Irwin © 2004 The McGraw-Hill Companies, Inc. All rights reserved. Outline Overview of Physical Database.
Module 9: Managing Schema Objects. Overview Naming guidelines for identifiers in schema object definitions Storage and structure of schema objects Implementing.
Oracle Database Administration Database files Logical database structures.
ASP.NET Programming with C# and SQL Server First Edition
Lecture 8 Index Organized Tables Clusters Index compression
Oracle Data Block Oracle Concepts Manual. Oracle Rows Oracle Concepts Manual.
Chapter 6 Additional Database Objects
1 © Prentice Hall, 2002 Physical Database Design Dr. Bijoy Bordoloi.
Constraints  Constraints are used to enforce rules at table level.  Constraints prevent the deletion of a table if there is dependencies.  The following.
Chapter 6 1 © Prentice Hall, 2002 The Physical Design Stage of SDLC (figures 2.4, 2.5 revisited) Project Identification and Selection Project Initiation.
CHAPTER 8 Indexes. Indexes Increase Query Speed An index is a database object used primarily to improve the performance of SQL queries The function of.
Chapter 6 Additional Database Objects Oracle 10g: SQL.
9 Storage Structure and Relationships. 9-2 Objectives Listing the different segment types and their uses Controlling the use of extents by segments Stating.
Oracle9i Database Administrator: Implementation and Administration 1 Chapter 7 Basic Table Management.
7 1 Chapter 7 Introduction to Structured Query Language (SQL) Database Systems: Design, Implementation, and Management, Seventh Edition, Rob and Coronel.
Database Management COP4540, SCS, FIU Physical Database Design (ch. 16 & ch. 3)
Oracle 10g Database Administrator: Implementation and Administration Chapter 7 Basic Table Management.
Database Systems Design, Implementation, and Management Coronel | Morris 11e ©2015 Cengage Learning. All Rights Reserved. May not be scanned, copied or.
Indexes / Session 2/ 1 of 36 Session 2 Module 3: Types of Indexes Module 4: Maintaining Indexes.
Dale Roberts Department of Computer and Information Science, School of Science, IUPUI Dale Roberts, Lecturer Computer Science, IUPUI
Week 3 Lecture 2 Basic Storage Concepts and Settings.
Week 4 Lecture 2 Advanced Table Management. Learning Objectives  Create tables with large object (LOB) columns and tables that are index-organized 
D Copyright © Oracle Corporation, All rights reserved. Loading Data into a Database.
Indexes and Views Unit 7.
Oracle 10g Database Administrator: Implementation and Administration Chapter 5 Basic Storage Concepts and Settings.
SQL/Lesson 7/Slide 1 of 32 Implementing Indexes Objectives In this lesson, you will learn to: * Create a clustered index * Create a nonclustered index.
Physical Database Design Purpose- translate the logical description of data into the technical specifications for storing and retrieving data Goal - create.
Partition Architecture Yeon JongHeum
Chapter 8 Physical Database Design. Outline Overview of Physical Database Design Inputs of Physical Database Design File Structures Query Optimization.
Managing Schema Objects
Chapter 5 Index and Clustering
Session 1 Module 1: Introduction to Data Integrity
Chapter 4 Indexes. Indexes Logically represents subsets of data from one or more tables View Generates numeric valuesSequence Basic unit of storage; composed.
Chapter 12 Additional Database Objects. Chapter Objectives  Define the purpose of a sequence and state how it can be used by an organization  Explain.
Indexes … WHERE key = Table Index 22 Row pointer Key Indexes
Data Warehousing Seminar Chapter 13 Indexing the Warehouse
Creating Indexes on Tables An index provides quick access to data in a table, based on the values in specified columns. A table can have more than one.
Chapter 12Introduction to Oracle9i: SQL1 Chapter 12 Additional Database Objects.
Unit 6 Seminar. Indexed Organized Tables Definition: Index Organized Tables are tables that, unlike heap tables, are organized like B*Tree indexes.
Dale Roberts 1 Department of Computer and Information Science, School of Science, IUPUI Dale Roberts, Lecturer Computer Science, IUPUI
Chapter 3 Table Creation and Management Oracle 10g: SQL.
1 Indexes ► Sort data logically to improve the speed of searching and sorting operations. ► Provide rapid retrieval of specified rows from the table without.
Indexes 22 Index Table Key Row pointer … WHERE key = 22.
Views / Session 3/ 1 of 40 Session 3 Module 5: Implementing Views Module 6: Managing Views.
Data Integrity & Indexes / Session 1/ 1 of 37 Session 1 Module 1: Introduction to Data Integrity Module 2: Introduction to Indexes.
Practical Database Design and Tuning
Indexing Structures for Files and Physical Database Design
Index An index is a performance-tuning method of allowing faster retrieval of records. An index creates an entry for each value that appears in the indexed.
Physical Database Design
Indexes and Basic Access Methods
Oracle 10g Database Administrator: Implementation and Administration
CHAPTER 5: PHYSICAL DATABASE DESIGN AND PERFORMANCE
Indexes … WHERE key = Table Index 22 Row pointer Key Indexes
Physical Database Design
Chapter 4 Indexes.
Microsoft SQL Server 2014 for Oracle DBAs Module 7
Understanding Indexes
Managing Indexes.
Presentation transcript:

Oracle9i Database Administrator: Implementation and Administration 1 Chapter 9 Index Management

Oracle9i Database Administrator: Implementation and Administration 2 Objectives  Learn the types of indexes Oracle offers and when to use each type  Understand how to create each type of index  Determine which data dictionary views contain information on indexes  Find out how to monitor index usage and when to drop an index  Learn how to modify, rebuild, and coalesce an index

Oracle9i Database Administrator: Implementation and Administration 3 Introduction to Indexes An index:  Is a database structure that speeds up data retrieval  Is automatically updated when rows are inserted updated or deleted Create indexes on:  Relational tables  Object tables  Nested tables  Index-organized tables  Partitioned tables

Oracle9i Database Administrator: Implementation and Administration 4 Introduction to Indexes An index:  Enforces PRIMARY KEY and UNIQUE constraints  Can have up to 32 (30 for bitmap) columns  Stores an entry for rows except those with all nulls in indexed columns (except bitmap, which stores all rows)

Oracle9i Database Administrator: Implementation and Administration 5 Introduction to Indexes Example of table and index data:

Oracle9i Database Administrator: Implementation and Administration 6 Types and Uses of Indexes The types of indexes offered in Oracle9i are:  B-tree index  Bitmap index  Local partitioned index  Global partitioned index and global nonpartitioned index  Reverse key index  Function-based index  B-tree cluster index  Hash cluster index  Domain index Oracle's default type Compact but limited For partitioned tables For Real Application Clusters New in Oracle9i For clusters -- not in scope For applications -- not in scope

Oracle9i Database Administrator: Implementation and Administration 7 Types and Uses of Indexes Syntax of CREATE INDEX command: CREATE UNIQUE|BITMAP INDEX. ON. ( | ASC|DESC, | ASC|DESC,..) TABLESPACE STORAGE ( ) LOGGING|NOLOGGING ONLINE COMPUTE STATISTICS NOCOMPRESS|COMPRESS NOSORT|REVERSE NOPARALLEL|PARALLEL PARTITION|GLOBAL PARTITION

Oracle9i Database Administrator: Implementation and Administration 8 Types and Uses of Indexes Components of CREATE INDEX command: UNIQUE / BITMAP ( | ASC|DESC,...) COMPUTE STATISTICS NOCOMPRESS / COMPRESS NOSORT / REVERSE NOPARALLEL / PARALLEL PARTITION / NOPARTITION

Oracle9i Database Administrator: Implementation and Administration 9 B-tree Index Similar to a binary tree algorithm:

Oracle9i Database Administrator: Implementation and Administration 10 B-tree Index B-tree structure example:

Oracle9i Database Administrator: Implementation and Administration 11 B-tree Index B-tree advantages over binary tree: Keeps the leaf nodes from getting too far down in the hierarchy Adds more values in each leaf node Adds more values in each branch node Allows each branch node to branch in more than two directions

Oracle9i Database Administrator: Implementation and Administration 12 B-tree Index Example: A unique, single column index: CREATE UNIQUE INDEX CLASSMATE.DEWEY_IX ON CLASSMATE.CH09LIBRARYBOOK (DEWEY_DECIMAL) INITRANS 2 PCTFREE 20 LOGGING COMPUTE STATISTICS;

Oracle9i Database Administrator: Implementation and Administration 13 Bitmap Index A bitmap index: Does not use b-tree algorithm Stores information in a bitmap More compact than b-tree index Useful only in certain circumstances:  Columns with low cardinality  Queries comply to a list of criteria of the way data is accessed  Few if any updates  Not unique and not using the DESC clause

Oracle9i Database Administrator: Implementation and Administration 14 Bitmap Index Example of CREATE BITMAP INDEX command: CREATE BITMAP INDEX PATIENT_BITMAP_X ON PATIENT (BLOOD_TYPE, GENDER);

Oracle9i Database Administrator: Implementation and Administration 15 Bitmap Index Example of bitmap structure:

Oracle9i Database Administrator: Implementation and Administration 16 Local Partitioned Index Created on a partitioned table Partitioned exactly like the table Advantage: Data changes inside a partition cause only that partition's index to be updated Faster performance if query uses one partition's data

Oracle9i Database Administrator: Implementation and Administration 17 Local Partitioned Index Examples: Local b-tree partitioned index: CREATE INDEX LOCAL_X ON CH09MORTGAGE_HISTORY(DATE_CREATED) LOCAL STORE IN (USERS, USER_AUTO); Local bitmap partitioned index: CREATE BITMAP INDEX MCLIENT_LOCAL_X ON CH09MORTGAGE_CLIENT(LOAN_DATE) LOCAL (PARTITION OLDER_X TABLESPACE USERS STORAGE (INITIAL 50K NEXT 10K), PARTITION NEWER_X TABLESPACE USER_AUTO STORAGE (INITIAL 40K NEXT 15K)); Oracle handles index partition names and storage settings

Oracle9i Database Administrator: Implementation and Administration 18 Local Partitioned Index Query the USER_IND_PARTITIONS to see partitioned index details:

Oracle9i Database Administrator: Implementation and Administration 19 Global Partitioned Index and Global Nonpartitioned Index Global partitioned index: On nonpartitioned table, or On partitioned table but index is partitioned differently than the table Global nonpartitioned index: Always on partitioned table Index is not partitioned

Oracle9i Database Administrator: Implementation and Administration 20 Global Partitioned Index Example: Range-partitioned index on hash-partitioned table: CREATE INDEX G_ACCT_X ON CH09MORTGAGE_HISTORY (ACCT_NO) GLOBAL PARTITION BY RANGE (ACCT_NO) (PARTITION LOWEST_ACCT VALUES LESS THAN (5000), PARTITION MIDDLE_ACCT VALUES LESS THAN (10000), PARTITION HIGHEST_ACCT VALUES LESS THAN (MAXVALUE));

Oracle9i Database Administrator: Implementation and Administration 21 Global Nonpartitioned Index Example: Nonpartitioned index on hash-partitioned table: CREATE UNIQUE INDEX G_LOAN_X ON CH09MORTGAGE_HISTORY (LOAN_NO) GLOBAL;

Oracle9i Database Administrator: Implementation and Administration 22 Reverse Key Index Useful when most queries access a group of index rows that are located physically close together Solves I/O bottleneck by distributing data more evenly Example: CREATE INDEX EVENT_REVERSE ON CURRENT_EVENTS(CREATE_DATE) REVERSE;

Oracle9i Database Administrator: Implementation and Administration 23 Function-Based Index New in Oracle9i Can only be used by the cost-based optimizer Index contains a function or expression in place of a column Stores the results of the expression in the index

Oracle9i Database Administrator: Implementation and Administration 24 Function-Based Index Examples: CREATE INDEX PUB_YEAR_IX ON CH09LIBRARYBOOK ( TO_CHAR(PUB_DATE,'YYYY') ); 9 CREATE INDEX TOTAL_PAIDX ON CH09MORTGAGE_CLIENT ( (MORTGAGE_AMOUNT*NUMBER_OF_YEARS*MORTGAGE_RATE) +MORTGAGE_AMOUNT ) TABLESPACE USERS STORAGE (INITIAL 20K NEXT 10K) LOGGING COMPUTE STATISTICS; Indexed function Indexed expression

Oracle9i Database Administrator: Implementation and Administration 25 Data Dictionary Information on Indexes Gather statistics periodically to keep data dictionary information current Helps optimizer performance Helps you find unused indexes Use: ANALYZE DBMS_STATS

Oracle9i Database Administrator: Implementation and Administration 26 Data Dictionary Information on Indexes Examples: DBMS_STATS: BEGIN DBMS_STATS.GATHER_SCHEMA_STATS (ownname=>'CLASSMATE',cascade=>TRUE); END; ANALYZE: ANALYZE INDEX TOTAL_PAIDX VALIDATE STRUCTURE;

Oracle9i Database Administrator: Implementation and Administration 27 Data Dictionary Information on Indexes Data dictionary views:

Oracle9i Database Administrator: Implementation and Administration 28 Managing Indexes Use ALTER INDEX to: Monitor Move Rename Restructure Coalesce Use DROP INDEX to remove an index Cannot change order of columns

Oracle9i Database Administrator: Implementation and Administration 29 Monitoring Indexes and Dropping Indexes Syntax for monitoring indexes: ALTER INDEX. MONITORING USAGE; To view monitoring results: SELECT * FROM V$OBJECT_USAGE; Syntax for dropping indexes: DROP INDEX. ;

Oracle9i Database Administrator: Implementation and Administration 30 Reorganizing and Modifying Indexes Use the ALTER INDEX command to: Reorganized an index Change storage settings Compute statistics Compress Coalesce

Oracle9i Database Administrator: Implementation and Administration 31 Reorganizing and Modifying Indexes Syntax of ALTER INDEX command: ALTER INDEX. REBUILD PARTITION|SUBPARTITION REVERSE|NOREVERSE TABLESPACE STORAGE (NEXT MAXEXTENTS ) PCTFREE COMPUTE STATISTICS COMPRESS|NOCOMPRESS LOGGING|NOLOGGING ONLINE; Clauses for indexes only Same meanings as in the ALTER TABLE statement

Oracle9i Database Administrator: Implementation and Administration 32 Reorganizing and Modifying Indexes The ALTER INDEX... REBUILD command: Automatically rebuilds the b-tree structure Automatically corrects an index that has been marked “UNUSABLE” due to change in table structure Can change a reverse key index to a normal index or vice versa

Oracle9i Database Administrator: Implementation and Administration 33 Reorganizing and Modifying Indexes Example of rebuilding an index: ALTER INDEX PUB_YEAR_IX REBUILD TABLESPACE USER_AUTO ONLINE;

Oracle9i Database Administrator: Implementation and Administration 34 Reorganizing and Modifying Indexes Syntax of additional clauses for ALTER INDEX: ALTER INDEX. COALESCE UPDATE BLOCK REFERENCES UNUSABLE ONLINE RENAME TO RENAME PARTITION TO DEALLOCATE UNUSED KEEP LOGGING|NOLOGGING NOPARALLEL|PARALLEL MONITORING USAGE|NOMONITORING USAGE; Same meanings as in the ALTER TABLE statement Clauses for indexes only

Oracle9i Database Administrator: Implementation and Administration 35 Reorganizing and Modifying Indexes Syntax components: COALESCE: Consolidate fragmented storage space in the leaf blocks Add DEALLOCATE UNUSED to deallocate unused space UPDATE BLOCK REFERENCES: Only for normal index-organized tables Updates the physical guesses of the indexed row’s location stored in the index

Oracle9i Database Administrator: Implementation and Administration 36 Reorganizing and Modifying Indexes UNUSABLE: Marks index unusable Optimizer ignores the index Example: ALTER INDEX DEWEY_IX COALESCE;

Oracle9i Database Administrator: Implementation and Administration 37 Chapter Summary An index is a structure that holds data and has its own storage in the database A normal index stores rows in order by the index key values There are nine types of indexes B-tree is Oracle’s default type of index

Oracle9i Database Administrator: Implementation and Administration 38 Chapter Summary B-tree indexes are efficient even for very large amounts of data Bitmap indexes take up far less storage space than b-tree indexes Local partitioned indexes mirror the partitioning of the partitioned table Global partitioned indexes can only be RANGE partitioned

Oracle9i Database Administrator: Implementation and Administration 39 Chapter Summary Function-based indexes substitute a function or expression for a column The ALTER INDEX command allows you to make changes to the index ALTER INDEX REBUILD can change storage settings and adjust b-tree leaves ALTER INDEX COALESCE can release unused space