Post on 25-Jan-2016
description
1
Comparison between Oracle and Teradata
Center of Excellence
Data Warehousing
Wipro Technologies
2
Basic Database Architecture Differences: Oracle
Oracle SMP
DBMS Kernel
Locking Logging Multi-Task Control
Global Buffer Pools
Global Systems/Storage Area
I/O I/O I/O I/O I/O I/O I/O I/O I/O I/OI/O I/O I/O I/OI/O
DataDataPartitionPartition
DataDataPartitionPartition
DataDataPartitionPartition
DataDataPartitionPartition
3
Basic Database Architecture Differences: Teradata
Teradata MPP
BYNET Connect
PE V-Proc
Lock
Log
M-T
BPool
I/O
AMP
PE V-Proc
BYNET Connect
PE V-Proc PE V-ProcBYNET
DataDataPartitionPartition
DataDataPartitionPartition
DataDataPartitionPartition
DataDataPartitionPartition
Lock
Log
M-T
BPool
I/O
AMP
Lock
Log
M-T
BPool
I/O
AMP
Lock
Log
M-T
BPool
I/O
AMP
Lock
Log
M-T
BPool
I/O
AMP
Lock
Log
M-T
BPool
I/O
AMP
Lock
Log
M-T
BPool
I/O
AMP
Lock
Log
M-T
BPool
I/O
AMP
DataDataPartitionPartition
DataDataPartitionPartition
DataDataPartitionPartition
DataDataPartitionPartition
SMP Node SMP Node
Oracle SMP
4
Oracle Physical Storage
Tablespaces are individual units of storage Tablespaces have associated data files
Data files can be added to, extended or removed from a tablespace dynamically
Only partitioned objects can span tablespaces
Logical objects are stored in physical segments. Segments consist of extents Object space is allocated one extent at a time. May cause fragmentation.
5
Disk Space and the Teradata Database
DBCStores
Products
TABLE
TABLE INDEX
INDEX
BYNET Connect
PE V-Proc
LockLog
M-T
BPoolI/O
AMP
PE V-Proc
BYNET Connect
PE V-Proc PE V-ProcBYNET
DataDataPartitionPartition
DataDataPartitionPartition
DataDataPartitionPartition
DataDataPartitionPartition
LockLog
M-T
BPoolI/O
AMP
LockLog
M-T
BPoolI/O
AMP
LockLog
M-T
BPoolI/O
AMP
LockLog
M-T
BPoolI/O
AMP
LockLog
M-T
BPoolI/O
AMP
LockLog
M-T
BPoolI/O
AMP
LockLog
M-T
BPoolI/O
AMP
DataDataPartitionPartition
DataDataPartitionPartition
DataDataPartitionPartition
DataDataPartitionPartition
SMP Node SMP Node
6
Sample Large Disk Space Allocation DDL
Oracle9i
Teradata
drop tablespace ts_o1 including contents;create tablespace ts_o1datafile’/export/home/oracle/oracle817/dbs/datafiles/o_1’ size8190m reuseextent management localautoallocate;
.
.
.
Repeat this for every tablespace
Execute OnceCREATE USER tpcd3000g AS PERM= 5400E9, PASSWORD= tpcd3000g;
7
Comparing Database CreationDatabase Creation Task Oracle Teradata
Script(s) to CreateCatalog/Data DictionaryTables and Views
Catalog.sql, Catclust.sql,Catproc.sql
DIP
Manage “In-FlightTransactional Data
Rollback/Undo Segments Transient Journal
Database Logs Redo Logs Permanent Journal
Temporary Space/WorkSpace
Temp Space Spool Space
Default Permanent Space Default Tablespace Default Database
Table Block Size Set at Table Level for Eachbut Requires DBA Setup ofBufferpools for Each BlockSize
Set at Table Level forEachTeradata MemoryManagement forDifferent Blocksizes isAutomatic
Database Startup Information INIT.ORA and Control File XCTL, Vconfig.out
8
Create Table Statements
CREATE TABLE Table1
( Col1 NUMBER,
Col2 NUMBER,
Col3 NUMBER )
TABLESPACE Tablespace1
STORAGE (INITIAL 6144 NEXT 6144
MINEXTENTS 1 MAXEXTENTS 5 );
or...
CREATE TABLE <expl|impl column specification>AS SELECT <any query>;
Oracle
CREATE TABLE Table1 ,FALLBACK ,
NO BEFORE JOURNAL, NO AFTER JOURNAL (Col1 INTEGER, Col2 INTEGER, Col3 INTEGER)UNIQUE PRIMARY INDEX ( Col1 );
Teradata
9
Creating Tables: Similarities
All tables have names Tables have columns with data types You can define:
Constraints Referential integrity Global temporary tables Triggers
10
Creating Tables: Differences Teradata tables are created in the database
or user
Teradata provides several convenient options: Fallback Permanent journaling Table block size Primary index Built into the Table MULTISET
DBC
ProductsTABLE
11
Partitioning
Partitioning tables and indexes allow Oracle and Teradata to store lots of data With Oracle, the process of choosing partitioning methods
and partitioning keys is the balancing of query access path, performance, and data load requirements
You specifically manage the partitioning constraints and their relationship to disk storage
With Teradata, the hash partitioning algorithm is very good at evenly distributing (loading) data partitions and is the basis for high performance data access and ease of user access
Provide reasonable partitioning columns when defining the table and Teradata does the rest
Partitioning Columns are Chosen for Even Data Distribution in Both Teradata and Oracle
12
Partitioning Comparisons - Oracle
Oracle Partitioning Decisions - Decide on Methods as well as partitioning columns, set up the disk environment
99Q1
99Q4
99Q3
99Q2 Hash1
Hash4
Hash3
Hash2
Texas
California
Florida
New York
Range Partitioning Hash Partitioning
Hash1
Hash3
Hash2
Hash3
Hash2
Hash1
99Q1
99Q2
99Q3
99Q4
Composite Range PartitioningList Partitioning
13
Partitioning Comparisons-Teradata
Teradata Partitioning is a Fact of the System with Hash Data Distribution based on Primary Index (Partitioning) Columns and system managed disk
AMP2 AMP3 AMP4
Table 1 Table 1Table 1Table 2 Table 2 Table 2
AMP1
Table 1Table 2
Table 3 Table 3Table 3 Table 3
14
Examples of DDL to Create Partitioned Tables
Oracle9i Teradatacreate table orders(o_orderdate date ,o_orderkey number NOT NULL,o_custkey number NOT NULL,o_orderpriority char(15) ,o_shippriority number ,o_clerk char(15) ,o_orderstatus char(1) ,o_totalprice number ,o_comment varchar(79))pctfree 1pctused 99initrans 10storage (freelists 99 freelist groups 2)parallelnologgingpartition by range (o_orderdate)subpartition by hash(o_custkey)subpartitions 16(partition ord1 values less than (to_date(’1992-01-01’,’YYYY-MM-DD’))tablespace ts_o1...partition ord84 values less than (MAXVALUE)tablespace ts_o84);
Repeat 82 Times with DBA Defined Ranges
CREATE MULTISET TABLE ORDERTBL, DATABLOCKSIZE= 29.5 KILOBYTES(O_ ORDERKEY DECIMAL (15,0) not null,O_ CUSTKEY INTEGER not null,O_ ORDERSTATUS CHAR( 1) CASESPECIFIC not null,O_ TOTALPRICE DECIMAL( 15,2) not null,O_ ORDERDATE DATE FORMAT ’yyyy- mm- dd’ not null,O_ ORDERPRIORITY CHAR( 15) CASESPECIFIC not null,O_ CLERK CHAR( 15) CASESPECIFIC not null,O_ SHIPPRIORITY INTEGER not null,O_ COMMENT VARCHAR( 79) CASESPECIFIC not null)UNIQUE PRIMARY INDEX( O_ ORDERKEY );
15
Oracle Parallelism
Oracle parallelism is not directly related to table partitioning because of its shared disk architecture Dynamically splits data over parallel processing units for
Selects/Inserts means 1 or more parallel processing units per partition
Considers partitioning when distributing data to parallel processing units
One parallel processing unit applied to each partition for Updates/Deletes
Each user/query can get varying amounts of parallelism or run serially depending upon the resources available at query run time
May need to manually control parallelism to improve system throughput and to ensure fair distribution of parallel resources Parallel processes may funnel down to serial processing for final
sort/merge, aggregate activity
16
Teradata Parallelism
Teradata parallelism is directly related to its shared nothing architecture Automatically applied by the database Architecture ensures that each major unit of parallelism (the VAMP)
has similar amounts of data and memory Pipelining and query step parallelism is performed within the VAMP
Utility Parallelism and Query/Data Manipulation Language parallelism (Select, Insert, Update, Delete) are all the same
All system parallelism is available to ALL operations Teradata parallelism is automatic, pervasive, and database managed
All users/queries take advantage of all the system parallel resources You do not manage and control parallelism
17
Data Types
CHAR VARCHAR2 NCHAR NCHAR2 NUMBER LONG LONGRAW RAW DATE BLOB CLOB NCLOB BFILE ROWID UROWID
CHAR VARCHAR CHAR VARYING LONG VARCHAR NUMERIC DECIMAL DOUBLE PRECISION FLOAT INTEGER SMALLINT BYTEINT BYTE VARBYTE GRAPHIC VARGRAPHIC LONG VARGRAPHIC DATE REAL
Oracle Teradata
18
Oracle Teradata
Char Char
Varchar2 Varchar
Number(m,n) DECIMAL(m,n) or NUMERIC(m,n)
Date (includestime)
Date (does not include time)
Date (time portion) Time
Date Timestamp
Data Type Translations
19
In Oracle the maximum precision "m" for number is 38. In Teradata it is 19
NUMBER (without precision) has no direct counterpart in Teradata. Determine migration by contents
ROWID has no counterpart in Teradata
Datatypes
20
Constraints
Like Teradata’s Constraints - Defined on columns and tables
Oracle is different from Teradata on the follow: Default mandatory is NULL Case sensitivity is fixed at ON Constraints can be disabled and enabled
21
Oracle Specific Columns and Table
ROWNUM will number retrieved rows
ROWID indicates physical address of row
SELECT must have FROM list DUAL is a pseudo-table with 1 row
22
Creating Indexes
Similarities between Teradata and Oracle: Indexes take up space on disk Indexes can be unique and non-unique Indexes and secondary indexes provide alternate
ways to access data Differences:
Teradata indexes are not in B-tree structure Hash Subtables
Teradata automatically partitions indexes across the AMPs
Teradata uses a Primary Index for each table
23
Index Usage Comparisons
Oracle solutions traditionally have relied heavily on indexes OLTP workloads required fast access paths to few rows Decision support solutions continue Oracle’s use of
indexes where tactical queries with OLTP-like response time requirements are given more emphasis than throughput performance
Teradata solutions have traditionally not used lots of indexes
Teradata’s efficient parallel architecture emphasizes throughput performance requirements - a result of it’s DSS background
24
Index Usage Comparisons Contd. Teradata typically uses fewer indexes than the equivalent Oracle
system Saves on disk storage Reduces table maintenance windows where affected by existing
indexes Fewer database objects to manage and monitor
Most of the indexes found in Oracle may not be used on Teradata Indexes can provide clues to ad hoc query support requirements No Bit-Map indexes for Teradata Add indexes to Teradata only as workloads (or anticipated
workloads) require them Monitor their usage or lack of usage
Statistics are key - you WANT to collect statistics in Teradata!
25
Principles Behind the Use of Indexes Maximize the use of Single or Few AMP Operations:
Drive towards using single or few AMP operations for queries Minimizing the number of AMPs in an operation, all other AMPs are freed to
perform other tasks. Scalability is increased because the freed AMPs can execute more single or few
AMP operations creating greater throughput by increasing the number of tactical queries executed in parallel
Create Efficient All AMP Operations: Reduce the resource consumption on each AMP for all AMP operations. Since all AMP operations are virtually impossible to remove from a data
warehousing environment, reducing the impact on each AMP is important Gain scalability for two reasons: Individual queries execute faster freeing the AMPs to execute other queries Decrease in resource consumption allows more queries to use the shared
resources, such as spool space, or CPU
26
Miscellaneous DDL
Triggers Triggers function just the same (pre- and post-, insert /
update / delete) as in Teradata Oracle Options not in Teradata
Database Links Reference (use) objects in another instance
Synonyms Named references to objects
Sequences Number generators Often used to generate surrogate keys
HierarchiesLK
E
27
ANALYZE/Collect Statistics
ANALYZE/DBMS_STATS package are intended for collecting database object statistics for Oracle’s Cost Based Optimizer (CBO)
Goal is to collect statistics give queries good access paths Once Plans are good and stable, stop analyzing tables to
preserve plans Teradata’s Collect Statistics command collects database object
statistics Optimizer reacts to changing demographics (growing tables,
changing column value cardinality, etc.) Keeping statistics up to date ensures good plans Don’t freeze statistics - old statistics encourage old access
plans that may not be effective as the database changes
28
Data Control Language
Data Control Language (DCL) is used in both Oracle and Teradata to assign user access
Oracle users may be granted: Object Privileges
Easily relate to Teradata System Privileges
Can be simulated within Teradata
29
User Access Rights
Teradata enables you to assign access rights: To individual users To logical groups of users On individual objects On groups of objects
ViewsViews
MacrosMacros
TablesTables
30
Object Privileges
Grant Execute Procedure/Grant Execute
Grant Execute
Grant UpdateGrant Update
Grant InsertGrant Insert
Grant SelectGrant Select
Grant Index orGrant Drop Table
Grant Index
Grant DeleteGrant Delete
Grant DropGrant Alter
Granting Teradata Privileges
Granting Oracle Privileges
31
System Privileges
Grant Drop View or Grant View on Database
Grant Drop Any View
Grant Create View or Grant View on Database
Grant Create Any View
Grant Create View or Grant View on Database
Grant Create View
Grant Select on DatabaseGrant Select Any Table
Grant Update on Database/Grant Update (column list, all but column list)
Grant Update Any Table
Grant Insert on Database Grant Insert Any Table
Grant Drop Table or Grant Table Grant Drop Any Table
Grant Delete on Database Grant Delete On Any Table
Grant Create Table or Grant Table Grant Alter Any Table
Grant Create Table or Grant Table Grant Create Table
Granting Teradata PrivilegesGranting Oracle Privileges
32
Questions ?