Tải bản đầy đủ (.ppt) (27 trang)

SQL Server - Bài 10

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (401.61 KB, 27 trang )

Managing Transaction and
Lock
Vu Tuyet Trinh

Hanoi University of Technology
1
MicrosoftMicrosoft
Transaction

A sequence of tasks that together constitute a logical unit
of work

Ensuring the highest level of integrity and consistency
within a database

Used when statements are processed
MicrosoftMicrosoft
ACID Properties

Atomicity

All or none

Consistency

Leave data in a consistent state

Isolation

Don’t show data that’s ½ done


Durability

Modifications are permanent
MicrosoftMicrosoft
Overview

Transaction

Review of Transaction Log

Introduction to Transactions and Locks

Managing Transactions

SQL Server Locking & Managing Locks
MicrosoftMicrosoft
Transaction Log Architecture

Write-Ahead transaction log

Flushing the page and dirty Pages

Use of checkpoints

Minimize what must be processed to recover

Truncating the transaction log

Shrinking the transaction log


DBCC SHRINKDATABASE

DBCC SHRINKFILE
MicrosoftMicrosoft
Transaction Recovery and Checkpoints
Transaction Recovery Action Required
None
Checkpoint System Failure
1
1
2
2
3
3
4
4
5
5
Roll forward
Roll back
Roll forward
Roll back
MicrosoftMicrosoft
Concurrency Control

Pessimistic concurrency control

High contention for data

Optimistic concurrency control


Low contention for data
MicrosoftMicrosoft
Lockable Resources


Item
Item


Description
Description
RID Row identifier
Key Row lock within an index
Page
Extent
Table
Data page or index page
Group of pages
Entire table
Database Entire database
MicrosoftMicrosoft
Types of Locks

Basic locks

Shared (LS)

Exclusive (LX)


Special situation locks

Intent

Update

Schema

Bulk update
MicrosoftMicrosoft
Lock Compatibility

Locks may or may not be compatible with other Locks

Examples

Shared locks are compatible with all locks except exclusive

Exclusive locks are not compatible with any other locks

Update locks are compatible only with shared locks
falsefalseLX
falsetrueLS
LXLS

Tài liệu bạn tìm kiếm đã sẵn sàng tải về

Tải bản đầy đủ ngay
×