SQL Server Locking Internals · SQL Server Locking Internals By Amit R S Bansal Director, Principal...
Transcript of SQL Server Locking Internals · SQL Server Locking Internals By Amit R S Bansal Director, Principal...
![Page 1: SQL Server Locking Internals · SQL Server Locking Internals By Amit R S Bansal Director, Principal Consultant & Trainer MVP, MCT, MCTS, etc..](https://reader033.fdocuments.in/reader033/viewer/2022053008/5f0b72427e708231d4308f1f/html5/thumbnails/1.jpg)
SQL Server Locking Internals
By
Amit R S Bansal Director, Principal Consultant & Trainer
www.PeoplewareIndia.com
www.amitbansal.net
MVP, MCT, MCTS, etc..
![Page 2: SQL Server Locking Internals · SQL Server Locking Internals By Amit R S Bansal Director, Principal Consultant & Trainer MVP, MCT, MCTS, etc..](https://reader033.fdocuments.in/reader033/viewer/2022053008/5f0b72427e708231d4308f1f/html5/thumbnails/2.jpg)
CTO, eDominer Systems & Peopleware India
Corporate Trainer/Consultant & Evangelist
Conducted more than 450+ workshops on SQL Server & BI for top notch IT companies world wide
Microsoft MVP for SQL Server
Speaker at TechED India, TechED US & TechED Europe
Speaking at SQLBITs this March in London
Technical Reviewer/SME – MSL courses & certifications on SQL Server
Co-Founder & President – SQLServerGeeks.com
Amit R S Bansal
![Page 3: SQL Server Locking Internals · SQL Server Locking Internals By Amit R S Bansal Director, Principal Consultant & Trainer MVP, MCT, MCTS, etc..](https://reader033.fdocuments.in/reader033/viewer/2022053008/5f0b72427e708231d4308f1f/html5/thumbnails/3.jpg)
About SQLServerGeeks.com
One of the fastest growing SQL Server communities
Blogs, Articles, Podcasts, In-person events, webcasts
Millions of page views
People behind SQLServerGeeks: Amit Bansal, Sarabpreet Singh, Parikshit Savjani, Abhay Chaudhary, Raunak Jhawar, Ahmed Osama, Amit Karkhanis, Vasudev Menon, Ritesh Medhe, Rakesh Mishra, Piyush Bajaj, Rahul Sharma, Satnam Singh, Bhagwan Singh
If you want to contribute, email us at [email protected] or visit Join Us section on the website
![Page 4: SQL Server Locking Internals · SQL Server Locking Internals By Amit R S Bansal Director, Principal Consultant & Trainer MVP, MCT, MCTS, etc..](https://reader033.fdocuments.in/reader033/viewer/2022053008/5f0b72427e708231d4308f1f/html5/thumbnails/4.jpg)
Gyan through demos !
Convert status
Conversion Lock
READ UNCOMMIITED myth
Intent Locking
Lock escalation
Partition-Level locking
Agenda
![Page 5: SQL Server Locking Internals · SQL Server Locking Internals By Amit R S Bansal Director, Principal Consultant & Trainer MVP, MCT, MCTS, etc..](https://reader033.fdocuments.in/reader033/viewer/2022053008/5f0b72427e708231d4308f1f/html5/thumbnails/5.jpg)
request_status = Convert
![Page 6: SQL Server Locking Internals · SQL Server Locking Internals By Amit R S Bansal Director, Principal Consultant & Trainer MVP, MCT, MCTS, etc..](https://reader033.fdocuments.in/reader033/viewer/2022053008/5f0b72427e708231d4308f1f/html5/thumbnails/6.jpg)
![Page 7: SQL Server Locking Internals · SQL Server Locking Internals By Amit R S Bansal Director, Principal Consultant & Trainer MVP, MCT, MCTS, etc..](https://reader033.fdocuments.in/reader033/viewer/2022053008/5f0b72427e708231d4308f1f/html5/thumbnails/7.jpg)
Conversion Locks
(SIX)
(SIU)
(UIX)
Happens when SQL Server already holds a lock at coarse granularity but now wants a lock at finer granularity.
![Page 8: SQL Server Locking Internals · SQL Server Locking Internals By Amit R S Bansal Director, Principal Consultant & Trainer MVP, MCT, MCTS, etc..](https://reader033.fdocuments.in/reader033/viewer/2022053008/5f0b72427e708231d4308f1f/html5/thumbnails/8.jpg)
![Page 9: SQL Server Locking Internals · SQL Server Locking Internals By Amit R S Bansal Director, Principal Consultant & Trainer MVP, MCT, MCTS, etc..](https://reader033.fdocuments.in/reader033/viewer/2022053008/5f0b72427e708231d4308f1f/html5/thumbnails/9.jpg)
READ UNCOMMITTED – neither does it ask for any locks nor does it honor any locks !
True or False?
Myth about READ UNCOMMITTED
![Page 10: SQL Server Locking Internals · SQL Server Locking Internals By Amit R S Bansal Director, Principal Consultant & Trainer MVP, MCT, MCTS, etc..](https://reader033.fdocuments.in/reader033/viewer/2022053008/5f0b72427e708231d4308f1f/html5/thumbnails/10.jpg)
![Page 11: SQL Server Locking Internals · SQL Server Locking Internals By Amit R S Bansal Director, Principal Consultant & Trainer MVP, MCT, MCTS, etc..](https://reader033.fdocuments.in/reader033/viewer/2022053008/5f0b72427e708231d4308f1f/html5/thumbnails/11.jpg)
What’s the purpose?
Performance?
Deadlocks?
Lock Escalation?
Latches?
INTENT Locks
![Page 12: SQL Server Locking Internals · SQL Server Locking Internals By Amit R S Bansal Director, Principal Consultant & Trainer MVP, MCT, MCTS, etc..](https://reader033.fdocuments.in/reader033/viewer/2022053008/5f0b72427e708231d4308f1f/html5/thumbnails/12.jpg)
![Page 13: SQL Server Locking Internals · SQL Server Locking Internals By Amit R S Bansal Director, Principal Consultant & Trainer MVP, MCT, MCTS, etc..](https://reader033.fdocuments.in/reader033/viewer/2022053008/5f0b72427e708231d4308f1f/html5/thumbnails/13.jpg)
What’s the purpose?
When does it happen?
Can you disable it? ALTER TABLE Production.Product
SET (LOCK_ESCALATION = AUTO|TABLE|DISABLE)
trace flag 1221 disables lock escalation completely
trace flag 1224 disables based on lock numbers
Should you disable it?
Lock escalation
![Page 14: SQL Server Locking Internals · SQL Server Locking Internals By Amit R S Bansal Director, Principal Consultant & Trainer MVP, MCT, MCTS, etc..](https://reader033.fdocuments.in/reader033/viewer/2022053008/5f0b72427e708231d4308f1f/html5/thumbnails/14.jpg)
![Page 15: SQL Server Locking Internals · SQL Server Locking Internals By Amit R S Bansal Director, Principal Consultant & Trainer MVP, MCT, MCTS, etc..](https://reader033.fdocuments.in/reader033/viewer/2022053008/5f0b72427e708231d4308f1f/html5/thumbnails/15.jpg)
New feature is SQL Server 2008
Does it mean Row -> Page -> Partition -> Table ?
True or False?
Partition Level Locking
![Page 16: SQL Server Locking Internals · SQL Server Locking Internals By Amit R S Bansal Director, Principal Consultant & Trainer MVP, MCT, MCTS, etc..](https://reader033.fdocuments.in/reader033/viewer/2022053008/5f0b72427e708231d4308f1f/html5/thumbnails/16.jpg)
![Page 17: SQL Server Locking Internals · SQL Server Locking Internals By Amit R S Bansal Director, Principal Consultant & Trainer MVP, MCT, MCTS, etc..](https://reader033.fdocuments.in/reader033/viewer/2022053008/5f0b72427e708231d4308f1f/html5/thumbnails/17.jpg)
Convert status
Conversion Lock
READ UNCOMMIITED myth
Intent Locking
Lock escalation
Partition-Level locking
Summary
![Page 18: SQL Server Locking Internals · SQL Server Locking Internals By Amit R S Bansal Director, Principal Consultant & Trainer MVP, MCT, MCTS, etc..](https://reader033.fdocuments.in/reader033/viewer/2022053008/5f0b72427e708231d4308f1f/html5/thumbnails/18.jpg)
Be a member - www.SQLServerGeeks.com
www.FaceBook.com/SQLServerGeeks
Twitter @SQLServerGeeks
Presentation & Scripts uploaded on www.SQLServerGeeks.com/files
Next webcast by Sarabpreet Singh on “Bulletproof Backup & Restore strategy”
Continue your learning…
![Page 19: SQL Server Locking Internals · SQL Server Locking Internals By Amit R S Bansal Director, Principal Consultant & Trainer MVP, MCT, MCTS, etc..](https://reader033.fdocuments.in/reader033/viewer/2022053008/5f0b72427e708231d4308f1f/html5/thumbnails/19.jpg)
Provide your feedback – you shall receive a mail shortly
Participate in quiz (on our forums)
Your chance to win:
And yes, lucky winners will be flashed on the site
Next steps…
![Page 20: SQL Server Locking Internals · SQL Server Locking Internals By Amit R S Bansal Director, Principal Consultant & Trainer MVP, MCT, MCTS, etc..](https://reader033.fdocuments.in/reader033/viewer/2022053008/5f0b72427e708231d4308f1f/html5/thumbnails/20.jpg)
www.AmitBansal.net
Like, Hate , LinkedIN, FB, Twitter, GuestBook
Connect with Amit Bansal
![Page 21: SQL Server Locking Internals · SQL Server Locking Internals By Amit R S Bansal Director, Principal Consultant & Trainer MVP, MCT, MCTS, etc..](https://reader033.fdocuments.in/reader033/viewer/2022053008/5f0b72427e708231d4308f1f/html5/thumbnails/21.jpg)