Example of Two Serial Transactions - Analytics Database - Teradata Vantage

SQL Request and Transaction Processing

Deployment
VantageCloud
VantageCore
Edition
Enterprise
IntelliFlex
VMware
Product
Analytics Database
Teradata Vantage
Release Number
17.20
Published
June 2022
ft:locale
en-US
ft:lastEdition
2024-10-04
dita:mapPath
zfm1628111633230.ditamap
dita:ditavalPath
qkf1628213546010.ditaval
dita:id
evd1472255317510
lifecycle
latest
Product Category
Teradata Vantage™

This example shows 2 transactions. The first transaction begins its operations before the second transaction.

Table Definition

Consider the following table definition:

     CREATE TABLE table_1 (
       column_1 INTEGER,
       column_2 INTEGER,
       column_3 INTEGER,
       column_4 INTEGER)
     PRIMARY INDEX (column_1);

Problem Transactions

The following two transactions are running concurrently, with the first having started prior to the second:

Transaction

Number

SQL Text
1
LOCKING table_1 FOR READ
CREATE INDEX (column_3, column_4) ON table_1;
2
SELECT *
FROM table_1
WHERE column_3 = 124
AND column_4 = 93;

Each transaction places a table-level READ lock on table_1. The transactions obtain access to table_1 and run concurrently.

The SELECT request does not recognize the index being created by the CREATE INDEX request.

Resolving the Problem

To eliminate concurrency, change the coding of transaction 1 to make its explicit lock EXCLUSIVE.

Transaction

Number

SQL Text
1
LOCKING table_1 FOR EXCLUSIVE
CREATE INDEX (column_3, column_4) ON table_1;
2
SELECT *
FROM table_1
WHERE column_3 = 124
AND column_4 = 93;

The upgraded LOCKING FOR EXCLUSIVE modifier in transaction 1 blocks the table-level READ lock request on table_1 in transaction 2.