0% found this document useful (0 votes)
163 views

Oracle DBA Basics 2

This document provides an overview of key Oracle Database 10g features including indexes, table partitions, Oracle Enterprise Manager, and analyzing SQL query plans. It discusses the types and benefits of indexes, how to create indexes, and when to use bitmap vs. B-tree indexes. Table partitioning methods like range, list and hash partitioning are explained along with their advantages. Oracle Enterprise Manager installation steps are outlined. Finally, examples are given of using EXPLAIN PLAN to analyze query plans and optimize performance.

Uploaded by

abhi9901
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
163 views

Oracle DBA Basics 2

This document provides an overview of key Oracle Database 10g features including indexes, table partitions, Oracle Enterprise Manager, and analyzing SQL query plans. It discusses the types and benefits of indexes, how to create indexes, and when to use bitmap vs. B-tree indexes. Table partitioning methods like range, list and hash partitioning are explained along with their advantages. Oracle Enterprise Manager installation steps are outlined. Finally, examples are given of using EXPLAIN PLAN to analyze query plans and optimize performance.

Uploaded by

abhi9901
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 19

Overview of Oracle Database 10g

1
Srinivasan.K
[email protected]
Agenda

 Oracle Index

 Table Partitions

 Oracle Enterprise Manager

 Analysing SQL Query plans

2
Oracle Index

 What is an 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 columns.
 By default, Oracle creates B-tree indexes.

 Types of Index
 B-Tree index
 Bitmap index

3
Oracle Index

 B-Tree index
 B(inary)-Tree Indexes are used on HIGH CARDINALITY
columns (i.e. columns which have relatively large number of
distinct values) or on HIGH SELECTIVITY columns (i.e.
columns having the capability to filter-out majority of the rows
when used in a WHERE clause).
 Examples of high SELECTIVITY columns are Primary key
columns & columns having relatively less number of duplicate
values.
 For instance, if a table has 1, 00,000 records and one of its
indexed columns have 81,000 distinct values, and then the
selectivity of the index is 0.81. Ideal selectivity for an indexed
column is 1 (which is true in the case of primary key indexes).

4
cont'd
Oracle Index

 Syntax :
CREATE [UNIQUE] INDEX index_name ON table_name (column1,
column2, . column_n);
For example :
CREATE INDEX supplier_idx ON supplier (supplier_name);
 Bitmap Index
 A bitmap index is a type of index that uses a string of bits to
quickly locate rows in a table
 Bitmap indexes are normally used to index low cardinality columns
in a warehouse environment.
 Syntax :
CREATE BITMAP INDEX <index_name> on
<table_name>(<column_name>);
5
cont'd
Table partitions

For example :
CREATE BITMAP INDEX emp_bitmap_idx
ON big_emp(sex);
 Table partitions
 Partitioning enables tables and indexes to be subdivided
into smaller manageable pieces and these each small
piece is called a "partition".
 From an "Application Development" perspective, there
is no difference between a partitioned and a non-
partitioned table.
 The application need not be modified to access a
partitioned table if that application was initially written on
a non partitioned tables.
Cont'd 6
Table partitions

 Advantages of using Partition’s in Table


 Smaller and more manageable pieces of data (Partitions)
 Reduced recovery time
 Failure impact is less
 Faster access of data
 Very easy to use.

 Types of Partitioning Methods:


 Range partitioning
 Hash partitioning
 List partitioning

cont'd
7
Table partitions
 Range partitioning
 This type of partitioning is useful when dealing with data that
has logical ranges into which it can be distributed
 Range partitions requires scalar numeric values.
 Performance is best when the data evenly distributes across
the range.
For example :
CREATE TABLE emp (
empno NUMBER(4),
ename VARCHAR2(30),
sal NUMBER )
PARTITION BY RANGE(empno) (
partition e1 values less than (1000) tablespace ts1,
partition e2 values less than (2000) tablespace ts2,
8
partition e3 values less than (MAXVALUE) tablespace ts3); comt'd
Table partitions
 List partitioning
 List partitioned is used when you require explicit control
over how rows map to partitions.
 Specify a list of discrete values for the partitioning column
in the description for each partition.
 List partitioning allows partitioning by non-scalar data.
For example :
CREATE TABLE myemp_work ( empno NUMBER PRIMARY KEY,
ename VARCHAR2(30),
salary NUMBER(8,2),
deptno NUMBER)
PARTITION BY LIST (deptno)
( PARTITION p10 VALUES (10),
PARTITION p20 VALUES (20),
9
PARTITION p30 VALUES (30,40)); cont'd
Table partitions

 Hash partitioning
 Partitions is based on a hashing algorithm
 Evenly distributing data between the partitions.
 This is typically used where ranges aren't appropriate, i.e. customer
number, product ID
For example :
CREATE TABLE sales_hash
(salesman_id NUMBER(5),
salesman_name VARCHAR2(30),
sales_amount NUMBER(10),
week_no NUMBER(2))
PARTITION BY HASH(salesman_id)
PARTITIONS 4
STORE IN (data1, data2, data3, data4);
The preceding statement creates a table sales_hash, which is hash partitioned
10
on salesman_id field. The tablespace names are data1, data2, data3, and data4. Cont'd
Oracle Enterprise Manager

 Oracle Enterprise Manager


 Perform administrative tasks such as creating schema objects
(tablespaces, tables, and indexes).
 Managing user security, backing up and recovering your
database, and importing and exporting data.
 View performance and status information about the database
instance.
 Installation steps
Login as oracle user in db server. Execute the below
commands.
$ emctl stop dbconsole
$ emca -deconfig dbcontrol db -repos drop
$ emca -config dbcontrol db -repos create
(or)
$ emca -config dbcontrol db -repos recreate 11
cont'd
12
13
Analysing Query plans

– What is an explain plan ?


The EXPLAIN PLAN statement displays execution plans
chosen by the Oracle optimizer for SELECT, UPDATE,
INSERT, and DELETE statements.
➢ A statement's execution plan is the sequence of
operations Oracle performs to run the statement.
– How to generate an explain plan ?
➢ sqlplus "/ as sysdba"
➢ sql > @$ORACLE_HOME/sqlplus/admin/plustrce.sql
➢ sql > grant PLUSTRACE to user;
➢ sql > GRANT UNLIMITED TABLESPACE TO user;
➢ sql > @?/rdbms/admin/utlxplan.sql
➢ sql > GRANT ALL ON sys.plan_table TO public;
➢ sql > create public synonym plan_table for sys.plan_table;
➢ conn user/user
➢ set autotrace traceonly explain 14
➢ select * from emp;
Analysing Query plans
Example 1
EXPLAIN PLAN SET statement_id = 'example_plan1' FOR
SELECT full_name FROM per_all_people_f
WHERE UPPER(full_name) LIKE 'Pe%' ;

Plan
---------------------------------------------
SELECT STATEMENT
TABLE ACCESS FULL PER_ALL_PEOPLE_F

This plan shows execution of a SELECT statement. The table per_all_people_f is


accessed using a full table scan.

* Every row in the table per_all_people_f is accessed, and the WHERE clause
criteria is evaluated for every row.
* The SELECT statement returns the rows meeting the WHERE clause criteria.

Cont'd 15
Analysing Query plans

Example 2
EXPLAIN PLAN SET statement_id = 'example_plan2' FOR
SELECT full_name FROM per_all_people_f
WHERE full_name LIKE 'Pe%' ;

Plan
---------------------------------------------
SELECT STATEMENT
TABLE ACCESS BY INDEX ROWID PER_ALL_PEOPLE_F
INDEX RANGE SCAN PER_PEOPLE_F_N54

This plan shows execution of a SELECT statement.


* Index per_people_f_n54 is used in a range scan operation.
* The table per_all_people_f is accessed through ROWID. ROWIDs are
obtained from the index in the previous step for keys that meet the WHERE
clause criteria. When the table is accessed, any additional WHERE clause
conditions that could not be evaluated during the range scan (because the
column is present in the table and not in the index) are also evaluated.
* The SELECT statement returns rows satisfying the WHERE clause
conditions (evaluated in previous steps). 16
Cont'd
Topics/References
 Oracle Index

http://www.lorentzcenter.nl/
http://www.techonthenet.com/
 Table Partitions
http://www.oracle-dba-online.com/
http://www.oracle-base.com/

 Oracle Enterprise Manager


http://download.oracle.com/
 Analysing SQL Query plans

http://www.oracle-base.com/
17
Q&A

18
THANKS

19

You might also like