Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
トランザクションの分離レベル(Isolation Level)について
Search
vividmuimui
June 07, 2017
Programming
100
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
トランザクションの分離レベル(Isolation Level)について
original
https://vividmuimui.github.io/slides/isolation-level/slides/
vividmuimui
June 07, 2017
Transcript
11 slides
トランザクションの分離レ トランザクションの分離レ ベル(Isolation Level) につ ベル(Isolation Level) につ いて いて
1
はじめに はじめに 極力、自信がないところは書かないように気を付けましたが、 間違っているところが有るかもしれないので、 このスライドの内容を鵜呑みせずに、 くわしくはググるか↓の記事を見てください。 このスライドはおもに↓の記事を参照しながら書きました。 http://qiita.com/kumagi/items/1dc1a91ec007365ac694 http://gyouza-daisuki.hatenablog.com/entry/2013/11/19/150838 https://ja.wikipedia.org/wiki/%E3%83%88%E3%83%A9%E3%83%B3%E3%82
2
分離レベルとは 分離レベルとは トランザクションが複数同時に行われた時に、 一つのトランザクションがほかの処理からどれだけ独立しているか、 ほかの処理に影響をどれだけ影響をあたえるのか、 を設定するもの。 3
分離レベルとは(2) 分離レベルとは(2) ANSI の定義だと、4 つの種類がある。 READ UNCOMMITTED READ COMMITTED REPEATABLE
READ SERIALIZABLE READ UNCOMMITTED が一番独立性が低い、下に行くほど高い ( という話もある) Web 開発者が知っておくべき八つの分離レベル 4
READ UNCOMMITTED READ COMMITTED PostgreSQL, Oracle, SQL Server REPEATABLE READ
Mysql, MariaDB SERIALIZABLE は性能は良いが独立性が低い、 は独立性は高いが性能が低い より http://qiita.com/kumagi/items/1dc1a91ec007365ac694 5
READ COMMITTED READ COMMITTED コミット済みのものはread する。 ファジーリード/Non-Repeatable Read Anomaly/Inconsistent Read
Anomaly x を2 回read しようとした時に、間に他トランザクションでx のwrite があった時に、read した内容が異なる Read Skew Anomaly x, y をread しようとした時に、他トランザクションでy のwrite があ った時に、read したx, y に一貫性がない Lost Update Anomaly 6
REPEATABLE READ REPEATABLE READ 一度読み込んだデータはそのトランザクション内では何度読んでも同じ値に なる。 ほかのトランザクションでwrite のコミットがされても、write 前のデータを read
していれば、write 後にread しても同じデータが読まれる。 ファントムリード 2 回範囲に対する操作をした時に、間にinsert が発生していると、結 果が異なる 2 回count しようとした時に、間で1 件insert されてた場合、2 回目は 1 件多い数字になる READ COMMITTED で発生してたAnomaly は発生しない 7
REPEATABLE READ(2) REPEATABLE READ(2) 同じtransaction 内で2 回read しようとしても結果は同じ。 => しかし、この仕組みのことを知らずに、
最新のデータを取るぞ!って思って2 回目のread をしても1 回目のread と同 じデータなので、 事故る可能性がある。 8
REPEATABLE READ(2) REPEATABLE READ(2) Mysql のInnnoDB では、ネクストキーロックという仕組みでファントムリー ドが起きないようにしている。 が、そのせいでギャップロックが発生する https://dev.mysql.com/doc/refman/5.6/ja/innodb-next-key-locking.html
9
言いたかったこと 言いたかったこと Rails を使っているとActiveRecord のお陰で、DB サーバーがMysql なのか PostgreSQL なのかを気にせず使えてとても便利。 だが、こういう違いが有ることを意識しておかないと事故る可能性がある。
10
最後に 最後に 極力、自信がないところは書かないように気を付けましたが、 間違っているところが有るかもしれないので、 このスライドの内容を鵜呑みせずに、 くわしくはググるか↓の記事を見てください。 このスライドはおもに↓の記事を参照しながら書きました。 http://qiita.com/kumagi/items/1dc1a91ec007365ac694 http://gyouza-daisuki.hatenablog.com/entry/2013/11/19/150838 https://ja.wikipedia.org/wiki/%E3%83%88%E3%83%A9%E3%83%B3%E3%82
11
More Decks by vividmuimui
See All by vividmuimui
あるチームでの技術選定で考えてること(外部向けに修正版)
vividmuimui
0
22
開発組織まわりで最近考えているあれこれ
vividmuimui
0
52
bundle-update.pdf
vividmuimui
0
130
Dependabot vs BundleUpdate+LockDiff
vividmuimui
0
120
あなたの知らないRuboCopの設定
vividmuimui
0
270
最近(2019/02/03)の #Ruby , #Rails , #Bundler 事情
vividmuimui
0
170
Jasperはいいぞ!
vividmuimui
0
61
Danger CI
vividmuimui
0
120
tigとかaliasなし生活を送ってみて改めてgitを覚えてる話
vividmuimui
0
140
Other Decks in Programming
See All in Programming
TS 7.0 で baseUrl が使えなくなった今、パスエイリアスをどうするか
bicstone
2
600
Web Framework Benchmark Battle 2026, Any%
a_matsuda
3
3.2k
Next.js: The final boss of Web Performance
guaca
0
400
AIがコードを書いてくれる時代、我々は何を確かめるのか
yosuke_furukawa
PRO
13
5.9k
LLM 101: Exploring LLMs, Starting with Tokens.
dalinaum
0
100
Secure Your Coding Agent Like It’s Malware (v1.5) 🇬🇧 @Code.talks 2026
richargh
0
120
SFCで実現する病院・医療システムの動的組み立て式UI
koukimiura
1
180
Getting Started with Vibe Coding
miccheng
0
200
SODA - FACT BOOK(EN)
sodainc
1
230
flutter_test のその先へ — Flutter アプリの LLM 機能に「評価」という品質保証を
kosukesaigusa
0
200
Herb in Rails 8.2: Your ERB views, now HTML-aware @ Kaigi on Rails 2026, Tokyo, Japan
marcoroth
2
430
Vapor Mode でアクセシビリティは 壊れないか検証した話
fuqda
1
340
Featured
See All Featured
Designing Powerful Visuals for Engaging Learning
tmiket
1
650
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
123
22k
Scaling GitHub
holman
464
140k
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
33
5.7k
The AI Revolution Will Not Be Monopolized: How open-source beats economies of scale, even for LLMs
inesmontani
PRO
3
3.8k
XXLCSS - How to scale CSS and keep your sanity
sugarenia
250
1.3M
Six Lessons from altMBA
skipperchong
29
4.6k
4 Signs Your Business is Dying
shpigford
187
23k
From Legacy to Launchpad: Building Startup-Ready Communities
dugsong
0
380
Stewardship and Sustainability of Urban and Community Forests
pwiseman
0
590
It's Worth the Effort
3n
188
29k
Applied NLP in the Age of Generative AI
inesmontani
PRO
4
2.6k