tailieunhanh - Hướng dẫn học Microsoft SQL Server 2008 part 141

tuyến đường nào là nhanh chóng tại 04:00 không có giao thông và tất cả các đèn màu xanh lá cây. Các trick là thiết kế một tuyến đường mà các công trình vào giờ cao điểm. Đồng thời là về sự tranh chấp. | Managing Transactions Locking and Blocking . -v Yr v ïA æa . Any route is fast at 4 00 . with no traffic and all green lights. The trick is designing a route that works during rush hour. Concurrency is about contention. Contention is a struggling together in opposition in which two users are trying to get hold of the same thing and it can apply to system resources or data. Managing resource contention is about writing code that uses as few resources as possible to enable as many users as possible to execute code at the same time. With database contention more than one user is trying to access the same resource within the database. For any complex system as the number of users increases performance decreases as each user competes for the same resources and the contention increases. This chapter focuses on the contention for data. Most people focus on system resource contention not on contention for database resources. Chapter 2 defined six database architecture design goals usability integrity scalability extensibility availability and security. Scalability is all about concurrency multiple users simultaneously attempting to retrieve and modify data. Here s why To ensure transactional integrity SQL Server by default uses locks to protect transactions from affecting other transactions. Specifically transactions that are reading data will lock that data which prevents or blocks other transactions from writing the same data. Similarly a transaction that s writing will prevent other transactions from writing or reading the same data. SQL Server maintains locks for the duration of a transaction so as more transactions occur simultaneously especially long transactions more resources are locked which results in more transactions being blocked. This can create a locking and blocking domino effect that bogs down the whole system. IN THIS CHAPTER Transactional integrity theory The transaction log and why it s important SQL Server locks and performance