Thanks to our platinum sponsors : Please add this slide add the start of your presentation after the first welcome slide Intro (5 minutes) Thank the sponsors Why does it matter Introduce yourself Locks (10 minutes) Why do we have locks? How do they connect to the data-objects we have? Data Structures (10 minutes) What kind of data structures do we have? NoLock Issues (5 minutes) How does NoLock effect the way data is being read Cascading Delete Read NoLock Speed Avoiding ( 10 minutes) PASS SQL Saturday Holland - 2016
Thanks to our gold and silver sponsors : Thank the sponsors Thank the audience Whom am I PASS SQL Saturday Holland - 2016
Why this talk Different people, Different ideas. Some people always want NoLock Some people always want to avoid NoLock Acid vs Base My hope is to give you the backgroup information so you can have an opinion on NoLock. Waarom dit onderwerp Kort de agenda Hoe werken locks in SQL Hoe wordt data gelezen Wat zijn manieren om locks te vermijden zonder NoLock.
What is a lock A lock is on an object; which can be a table, a partition, a page, or a row. Is, s, iu, u, ix, x etc etc
What is the process we will be seeing a lot during this talk. A Query gets executed First it creates an Intent Lock When it gathers enough free Intent Locks, it tries to upgrade them to lock the resource Then executes the query To fake a state, or increase the duration we add an explicit transaction
1.(S) locks are compatible with (S) and (U) locks. 2.(X) locks are incompatible with any other lock types 3.(U) locks are compatible with (S) but incompatible with (U) Update locks worden gehouden tot ze data modificeren excusive lock
DEMO Quick_overview_locks
What did we just see? Locks are designed to prevent you from reading unwanted results Locks are in different types of heaviness and can co-exist! Transactions influence locking behaviour Quick_overview_locks
Isolation levels Serializable Repeatable Read Read Committed No update/delete/insert Repeatable Read No Delete/Updates Read Committed You can change, I’ll just adept Read Uncommitted You are planning to do something? Let’s act on it. Nolock breaks any isolation-level; it lets SQL believe it’s reading non-changing data.
What is a page-split
DEMO Create_PageSplit Cascading_Deletes
Page SlotArray is de plek waar verteld wordt waar de data staat.
Two ways of accessing data
Adding data to a page
DEMO Read_NoLock_Speed.sql Quick Allocation
Recap A Data-row is the smallest entity. There is a reference in each page and two ways of getting to the data. Optionally template for your own slide
Possible solutions Determine your requirements. Avoid Lock escalation Batch your queries / transactions Snapshot Isolation (silver bullet) Design Properly
Airplanes; if it’s in transition and you don’t get data back to the system.. It’s very very likely to be in the progress of being taken. Thusly it doesn’t matter if we don’t read the data; we can assume what the outcome is.
Demo Avoiding_Lock_Escalation (dirty) AvoidingDeadlockByIndex
Please fill in the evaluation forms Please add this slide add the end of your presentation to get feedback from the audience
Used scripts