Query Optimization
Query Optimization
algorithms or re-written in different forms and structures. Hence, the question of query
optimization comes into the picture – Which of these forms or pathways is the most
optimal? The query optimizer attempts to determine the most efficient way to execute a
given query by considering the possible query plans.
Transaction
A transaction is an action or series of actions that are being performed by a single user
or application program, which reads or updates the contents of the database.
A transaction can be defined as a logical unit of work on the database. This may be an
entire program, a piece of a program, or a single command (like the SQL commands
such as INSERT or UPDATE), and it may engage in any number of operations on the
database. In the database context, the execution of an application program can be
thought of as one or more transactions with non-database processing taking place in
between.
A simple example of a transaction will be dealing with the bank accounts of two users,
let say Scott and Smith. A simple transaction of moving an amount of 5000 from Scott to
Smith engages many low-level jobs. As the amount of Rs. 5000 gets transferred from
the Scott’s account to Smith’s account, a series of tasks gets performed in the
background of the screen.
This straightforward and small transaction includes several steps: decrease Smith's
bank account from 5000:
Open_Acc (Scott
OldBal = Scott.al
Ramt.al = NewBal
CloseAccount(Scott
You can say, the transaction involves many tasks, such as opening the account of
Scott, reading the old balance, decreasing the specific amount of 5000 from that
account, saving new balance to an account of Scott, and finally closing the transaction
session.
For adding amount 5000 in Smith’s account, the same sort of tasks needs to be done:
OpenAccount(Smitht
Old_Bal = Smitht.al
Ahmedt.al = NewBal
CloseAccount(Bt
Properties of Transaction
There are properties that all transactions should follow and possess. The four basic are
in combination termed as ACID properties. ACID properties and its concepts are as
follows: