Skip to content

Commit bcf3bdc

Browse files
committed
Enhance README with grammar corrections, clearer explanations, and better formatting
1 parent 6378609 commit bcf3bdc

1 file changed

Lines changed: 20 additions & 16 deletions

File tree

  • samples/features/optimized-locking/transaction-id-locking

samples/features/optimized-locking/transaction-id-locking/README.md

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
# Optimized Locking: Transaction ID (TID) locking internals
55

6-
This sample describes how to read and interpret the Transaction ID stored in row data pages.
6+
This sample describes how to read and interpret the Transaction ID (TID) stored in row data pages.
77

88
## Background
99

@@ -17,15 +17,15 @@ Optimized Locking is based on two key mechanisms:
1717
- Transaction ID (TID) locking
1818
- Lock After Qualification (LAQ)
1919

20-
### What is the Transaction ID?
20+
### What is the Transaction ID (TID)?
2121

2222
The Transaction ID (TID) is a unique transaction identifier.
2323

2424
When a [row-versioning based isolation level](https://learn.microsoft.com/en-us/sql/relational-databases/sql-server-transaction-locking-and-row-versioning-guide#Row_versioning) is active, or when [Accelerated Database Recovery (ADR)](https://learn.microsoft.com/sql/relational-databases/accelerated-database-recovery-concepts) is enabled, every row in the database internally contains a transaction identifier.
2525

2626
The TID is stored on disk in the additional 14 bytes that are associated with each row when features such as RCSI or ADR are enabled.
2727

28-
Every transaction that modifies a row, it tags that row with its own TID, so each row in the database is labeled with the last TID that modified it.
28+
Every transaction that modifies a row tags that row with its own TID, so each row in the database is labeled with the last TID that modified it.
2929

3030
### Contents
3131

@@ -59,15 +59,15 @@ To run this sample, you need the following prerequisites.
5959

6060
### Setup code
6161

62-
1. Download [create-configure-optimizedlocking-db.sql](sql-scripts) T-SQL script from sql-scripts folder
63-
2. Check if a database called OptimizedLocking does not exist in your SQL Server instance
62+
1. Download [create-configure-optimizedlocking-db.sql](sql-scripts/create-configure-optimizedlocking-db.sql) T-SQL script from sql-scripts folder
63+
2. Verify that a database named OptimizedLocking does not already exist in your SQL Server instance
6464
3. Execute create-configure-optimizedlocking-db.sql script on your SQL Server instance
6565
4. Run the commands described in the sample details section
6666

6767
<a name=sample-details></a>
6868
## Sample Details
6969

70-
Currently, the only way to read the Transaction ID of a row is by using the `DBCC PAGE` command.
70+
Currently, the only way to read the TID of a row is by using the `DBCC PAGE` command.
7171

7272
Let's consider the table dbo.TelemetryPacket, with the schema defined in the following T-SQL code snippet.
7373

@@ -108,30 +108,32 @@ FROM
108108
dbo.TelemetryPacket;
109109
```
110110

111-
The output is similar to the following, except to the values in PageId column.
111+
The output is similar to the following, except for the values in the PageId column.
112112

113113
| PageId | PacketID | Device |
114114
| ----------- | --------- | --------- |
115115
| (1:2456:0) | 1 | Something |
116116
| (1:2457:0) | 2 | Something |
117117
| (1:2458:0) | 3 | Something |
118118

119-
The values shown in the PageId column represent the physical location of the data.
119+
Each value in the PageId column follows the format **(FileID:PageID:SlotID)** and represents the physical location of the data.
120120

121-
Let's look at the row where PacketID equals 1.
122-
123-
The value (1:2456:0) in the PageId column is composed of three parts separated by ":". Here is what each part represents:
124-
- 1 is the numeric identifier of the database file (file number) where the page is located
125-
- 2456 is the page number inside file 1 of the database
126-
- 0 is the slot number
121+
Let's examine the row where PacketID equals 1. The value (1:2456:0) is composed of three parts separated by ":". Here is what each part represents:
122+
- **1** - the numeric identifier of the database file (FileID)
123+
- **2456** - the page number within the file (PageID)
124+
- **0** - the slot number on the page (SlotID)
127125

128126
Use the `DBCC PAGE` command to inspect the TID of page 2456.
129127

130128
```sql
129+
-- Enable trace flag for DBCC PAGE output
130+
DBCC TRACEON(3604);
131+
GO
132+
131133
DBCC PAGE ('OptimizedLocking', 1, 2456, 3);
132134
```
133135

134-
The value of the unique transaction identifier (TID) that modified the row with PacketID equal to 1 is in the **Version Information** section, under the **Transaction Timestamp** attribute, as shown in the following sample data.
136+
The value of the unique TID that modified the row with PacketID equal to 1 is in the **Version Information** section, under the **Transaction Timestamp** attribute, as shown in the following sample data.
135137

136138
```sql
137139
Version Information =
@@ -151,7 +153,9 @@ TID 985 represents the identifier of the transaction that inserted the rows; eve
151153

152154
The code included in this sample is not intended to be a set of best practices on how to build scalable enterprise grade applications. This is beyond the scope of this sample.
153155

156+
> **Note:** The `DBCC PAGE` command is undocumented and intended for troubleshooting and diagnostic purposes only. It should not be used in production environments without proper understanding and testing.
157+
154158
<a name=related-links></a>
155159
## Related Links
156160

157-
- [Optimized locking](https://learn.microsoft.com/sql/relational-databases/performance/optimized-locking)
161+
- [Optimized locking](https://learn.microsoft.com/sql/relational-databases/performance/optimized-locking)

0 commit comments

Comments
 (0)