Presentation is loading. Please wait.

Presentation is loading. Please wait.

Data Warehousing Group Transaction Processing

Similar presentations


Presentation on theme: "Data Warehousing Group Transaction Processing"— Presentation transcript:

1 Data Warehousing Group Transaction Processing
Last Updated : 27th April 2004 Center of Excellence Data Warehousing Group Transaction Processing

2 Requests A request to Teradata Database consists of one or more SQL statements. Single Statement Requests Multi Statement Requests. An SQL statement can be submitted from a BTEQ script an embedded application program. a stored procedure a CLI, ODBC, JDBC program.

3 Multi-Statement Requests
A multi-statement request consists of multiple SQL statements separated by semicolon. Treated as a single unit of work. Either all statements in the request complete successfully or the entire request is aborted. Multi-statement requests are non-ANSI SQL-99 standard. Multi-statement requests improve performance by reducing processing overhead.

4 Transactions A transaction is a logical unit of work.
Statements nested within the transaction either execute successfully as a group or do not execute. ANSI Mode Teradata Mode.

5 ANSI Mode Transactions are always implicit in ANSI session mode.
A transaction initiates when : The first SQL statement in a session executes The first statement following the close of a session executes. COMMIT or ROLLBACK/ABORT statements close a transaction. If a transaction includes a DDL statement, it must be the last statement in the transaction. Error results roll back only the present request not the entire transaction.

6 Teradata Mode A Teradata SQL transaction can be a single SQL statement, or a sequence of SQL statements, treated as single unit of work. Implicit Explicit Starts with BEGIN TRANSATION statement. Ends with END TRANSACTION statement. If a transaction includes a DDL statement, it must be the last statement in the transaction. Error results roll back the entire transaction. Transactions are atomic - either all requests are performed, or none are.

7 Transaction Locks Lock Levels Types of Locks Database Level Locks
Table Level Locks Row Hash Locks Types of Locks Exclusive Locks Write Locks Read Locks Access Locks

8 Locking Compatibility
Lock Mode Requested Locking Mode Held None Access Read Write Exclusive Lock Granted Request Queued

9 A Deadlock Example BT; SELECT * FROM TABLE1; UPDATE table1
SET col1 = <value1> WHERE col1 = pqr; ET; BT; LOCK TABLE1 FOR WRITE; SELECT * FROM TABLE1; UPDATE table1 SET col1 = <value1> WHERE col1 = pqr; ET; BT; SELECT * FROM TABLE1; UPDATE table1 SET col1 = <value1> WHERE col1 = xyz; ET; BT; LOCK TABLE1 FOR WRITE; SELECT * FROM TABLE1; UPDATE table1 SET col1 = <value1> WHERE col1 = xyz; ET;

10 Deadlock Prevention Develop your applications to avoid deadlock situations. Sometimes Deadlocks are unavoidable. Plan for graceful recovery whenever a deadlock. If a multistatement transaction aborted due to a deadlock, the entire transaction must be executed again. Use “LOCK FOR ACCESS” modifier when “dirty reads” are accepatble.

11 Questions ?


Download ppt "Data Warehousing Group Transaction Processing"

Similar presentations


Ads by Google