Blog Post

Transaction Isolation Level Blues

,

Have you ever had a mental block in one particular area when learning something? It might be the simplest thing, but for some reason your brain turns to Teflon when you try to store the information. For example, I have a degree in Math, so I am pretty good at arithmetic, but for the life of me I cannot remember what eight plus five is. I always have to break out my phalanges to get the answer.  Why the Hell can I remember what phalanges means and not a simple thing like eight plus five?!

I have this same problem when it comes to Transaction Isolation Levels in SQL Server. I can remember that there are five of them, Read Uncommitted, Read Committed, Repeatable Read, Snapshot & Serializable, but I cannot remember the little nuances that set them apart. It’s total Teflon. So I decided it was time to come up with a little song to help me remember. My older sister is a preschool teacher and she says that if you learn something as a song, it sticks with you for life. Here’s hoping that is true!

This is sung to the tune of George Thorogood’s Bad to the Bone.

At the time I am used

No Shared locks are issued

Not blocked by X locks

It is Loosey-Goosey

Just call me crazy

No restrictions abound

I could tell right away

It was Read Uncommitted

Bad to the bone

Bad to the bone

B-B-B-B-Bad

B-B-B-B-Bad

B-B-B-B-Bad

Bad to the bone

Not breakin’ any rules

Going by the book

Not readin’ any uncommitted

Transactions it’s true

I am the default baby

Transactions alone

I’m Read Committed

That’s what I do

Bad to the bone

B-B-B-Bad

B-B-B-Bad

B-B-B-Bad

Bad to the bone

No readin’ ’til committed

Can’t read dirty data either

I use shared locks baby

And hold ’til committed

I’m the repeatable read baby

Yours and yours alone

Data’s all yours honey

And I’m bad to the bone

B-B-B-B-Bad

B-B-B-B-Bad

B-B-B-B-Bad

Bad to the bone

When I query data

Kings and Queens step aside

Every bit I meet

It’s mine it’s all mine

Serializable baby

Range blocks on keys that’s me

HOLDLOCK does the same thing baby

Serializable oo-ee

Bad to the bone

B-B-B-B-Bad

B-B-B-Bad

B-B-B-Bad

Bad to the bone

(Extra verse)

There’s no write blockin’

While I’m readin’

No locks less I’m recoverin’

You can’t switch to me

But I can switch to you

I’m a snapshot baby

A photo just for you

Bad to the bone

B-B-B-B-Bad

B-B-B-Bad

B-B-B-Bad

Bad to the bone

If your brain is Teflon when it comes to Transaction Isolation Levels, then I hope this helps. If not, I hope you got a good laugh and please don’t tell George Thorogood what I did to one of his best songs (and one of my favorites).

By the way, eight plus five is .. thirteen.

Rate

You rated this post out of 5. Change rating

Share

Share

Rate

You rated this post out of 5. Change rating