sql server locking internals · sql server locking internals by amit r s bansal director, principal...

22
SQL Server Locking Internals By Amit R S Bansal Director, Principal Consultant & Trainer www.PeoplewareIndia.com www.amitbansal.net MVP, MCT, MCTS, etc..

Upload: others

Post on 23-Jun-2020

6 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: SQL Server Locking Internals · SQL Server Locking Internals By Amit R S Bansal Director, Principal Consultant & Trainer   MVP, MCT, MCTS, etc

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

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

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

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

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
Page 7: SQL Server Locking Internals · SQL Server Locking Internals By Amit R S Bansal Director, Principal Consultant & Trainer   MVP, MCT, MCTS, etc

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
Page 9: SQL Server Locking Internals · SQL Server Locking Internals By Amit R S Bansal Director, Principal Consultant & Trainer   MVP, MCT, MCTS, etc

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
Page 11: SQL Server Locking Internals · SQL Server Locking Internals By Amit R S Bansal Director, Principal Consultant & Trainer   MVP, MCT, MCTS, etc

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
Page 13: SQL Server Locking Internals · SQL Server Locking Internals By Amit R S Bansal Director, Principal Consultant & Trainer   MVP, MCT, MCTS, etc

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
Page 15: SQL Server Locking Internals · SQL Server Locking Internals By Amit R S Bansal Director, Principal Consultant & Trainer   MVP, MCT, MCTS, etc

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
Page 17: SQL Server Locking Internals · SQL Server Locking Internals By Amit R S Bansal Director, Principal Consultant & Trainer   MVP, MCT, MCTS, etc

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

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

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

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
Page 22: SQL Server Locking Internals · SQL Server Locking Internals By Amit R S Bansal Director, Principal Consultant & Trainer   MVP, MCT, MCTS, etc

Thank you

for suggestions, please email at [email protected]