Innodb Multi-Versioning - Oracle 5.0 Reference Manual

Table of Contents

Advertisement

• Add well-chosen indexes to your tables. Then your queries need to scan fewer index records and
consequently set fewer locks. Use
regards as the most appropriate for your queries.
• Use less locking. If you can afford to permit a
add the clause
isolation level is good here, because each consistent read within the same transaction reads from its
own fresh snapshot. You should also set the value of
reduce the number of disk flushes due to synchronizing on disk data and the binary log.
• If nothing else helps, serialize your transactions with table-level locks. The correct way to use
LOCK TABLES
autocommit = 0
until you commit the transaction explicitly. For example, if you need to write to table
TABLES
read from table t2, you can do this:
SET autocommit=0;
LOCK TABLES t1 WRITE, t2 READ,
COMMIT;
UNLOCK TABLES;
Table-level locks make your transactions queue nicely and avoid deadlocks.
• Another way to serialize transactions is to create an auxiliary "semaphore" table that contains just
a single row. Have each transaction update that row before accessing other tables. In that way, all
transactions happen in a serial fashion. Note that the
also works in this case, because the serializing lock is a row-level lock. With MySQL table-level
locks, the timeout method must be used to resolve deadlocks.
14.2.8.
Multi-Versioning
InnoDB
Because
InnoDB
rows in the tablespace. This information is stored in a data structure called a rollback segment (after an
analogous data structure in Oracle).
Internally,
InnoDB
indicates the transaction identifier for the last transaction that inserted or updated the row. Also, a
deletion is treated internally as an update where a special bit in the row is set to mark it as deleted.
Each row also contains a 7-byte
undo log record written to the rollback segment. If the row was updated, the undo log record contains
the information necessary to rebuild the content of the row before it was updated. A 6-byte
field contains a row ID that increases monotonically as new rows are inserted. If
clustered index automatically, the index contains row ID values. Otherwise, the
does not appear in any index.
uses the information in the rollback segment to perform the undo operations needed in a
InnoDB
transaction rollback. It also uses the information to build earlier versions of a row for a consistent read.
Undo logs in the rollback segment are divided into insert and update undo logs. Insert undo logs
are needed only in transaction rollback and can be discarded as soon as the transaction commits.
Update undo logs are used also in consistent reads, but they can be discarded only after there is no
transaction present for which
the information in the update undo log to build an earlier version of a database row.
You must remember to commit your transactions regularly, including those transactions that issue only
consistent reads. Otherwise,
segment may grow too big, filling up your tablespace.
The physical size of an undo log record in the rollback segment is typically smaller than the
corresponding inserted or updated row. You can use this information to calculate the space need for
your rollback segment.
InnoDB
EXPLAIN SELECT
or
FOR UPDATE
LOCK IN SHARE MODE
with transactional tables, such as
(not
TRANSACTION) followed by
START
...;... do something with tables t1 and t2 here ...
is a multi-versioned storage engine, it must keep information about old versions of
adds three fields to each row stored in the database. A 6-byte
DB_ROLL_PTR
has assigned a snapshot that in a consistent read could need
InnoDB
cannot discard data from the update undo logs, and the rollback
InnoDB
Multi-Versioning
to determine which indexes the MySQL server
to return data from an old snapshot, do not
SELECT
to it. Using the
innodb_support_xa
tables, is to begin a transaction with
InnoDB
LOCK
instant deadlock detection algorithm
InnoDB
field called the roll pointer. The roll pointer points to an
1275
READ COMMITTED
[1250]
to 0, which will
TABLES, and to not call
DB_TRX_ID
DB_ROW_ID
generates a
InnoDB
column
DB_ROW_ID
[1121]
SET
UNLOCK
and
t1
field

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the 5.0 and is the answer not in the manual?

Questions and answers

This manual is also suitable for:

Mysql 5.0

Table of Contents