Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
The underground in ActiveRecord::ConnectionAdap...
Search
Koichi ITO
March 10, 2018
Programming
6
3.5k
The underground in ActiveRecord::ConnectionAdapters
沖縄Ruby会議02
http://ruby.okinawa/okrk02/
Koichi ITO
March 10, 2018
Tweet
Share
More Decks by Koichi ITO
See All by Koichi ITO
Carving the Way to Ruby Engineering
koic
3
460
Beyond the RuboCop Defaults
koic
3
3k
Minify Ruby Code
koic
2
2.2k
Permanent Agility
koic
37
7.7k
RuboCop: LSP and Prism
koic
3
4.2k
Organizational Pattern Hatching
koic
0
1.5k
A Practitioner's Journey from Ruby 1.8 to Present
koic
1
2k
A Story Featuring Right Hand Archetype
koic
0
1.1k
Without Practice, No Emergence
koic
4
2.4k
Other Decks in Programming
See All in Programming
見えないメモリを観測する: PHP 8.4 `pg_result_memory_size()` とSQL結果のメモリ管理
kentaroutakeda
0
450
103 Early Hints
sugi_0000
1
250
htmxって知っていますか?次世代のHTML
hiro_ghap1
0
350
Zoneless Testing
rainerhahnekamp
0
120
【re:Growth 2024】 Aurora DSQL をちゃんと話します!
maroon1st
0
790
快速入門可觀測性
blueswen
0
400
Monixと常駐プログラムの勘どころ / Scalaわいわい勉強会 #4
stoneream
0
280
testcontainers のススメ
sgash708
1
120
アクターシステムに頼らずEvent Sourcingする方法について
j5ik2o
4
320
KMP와 kotlinx.rpc로 서버와 클라이언트 동기화
kwakeuijin
0
170
PHPで学ぶプログラミングの教訓 / Lessons in Programming Learned through PHP
nrslib
3
340
技術的負債と向き合うカイゼン活動を1年続けて分かった "持続可能" なプロダクト開発
yuichiro_serita
0
120
Featured
See All Featured
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
17
2.3k
Chrome DevTools: State of the Union 2024 - Debugging React & Beyond
addyosmani
3
170
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
232
17k
Product Roadmaps are Hard
iamctodd
PRO
49
11k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
26
1.5k
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
127
18k
The Language of Interfaces
destraynor
154
24k
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
33
2k
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
6
450
Scaling GitHub
holman
459
140k
Measuring & Analyzing Core Web Vitals
bluesmoon
4
170
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
28
9.1k
Transcript
"DUJWF3FDPSE $POOFDUJPO"EBQUFST ͷԼͷੈ ք ླྀٿେֶֶ෦߸ؗ 4BU ԭೄ3VCZձٞ 5IFVOEFSHSPVOEJO"3$POOFDUJPO"EBQUFST %JWFUPUIFSBJMTSBJMTSFQPTJUPSZ
ג ӬγεςϜϚωδϝϯτ ҏ౻ߒҰ !LPJD
None
None
ࠓͷ
None
None
None
w %JWFUPSBJMTSBJMTSFQP w "3$POOFDUJPO"EBQUFST w 0SBDMFFOIBODFEBEBQUFS w 0SBDMFXJUI3BJMT "HFOEB ˞#BTFEPO3BJMTSD
Dive to rails/rails
None
None
None
None
None
None
AR::ConectionAdapters
w "3ͷϞσϧܦ༝Ͱͷݺͼग़͠ʹର͠ ͯɺ3%#.4͝ͱʹཧʹ͔ͳͬͨ42- ΛΈཱͯͯฦׂ͢ w 3%#.4ͷ༷Λલఏ͢Δɻྫ͑ 0SBDMFͩͱۭจࣈͱ/6--Λ۠ผ͠ ͳ͍ɺHἬࣝผࢠ͕จࣈҎԼ "3$POOFDUJPO"EBQUFST
SBJMTSBJMTͷςετͰΔ3%#.4ͷ ༷ʹΑΔৼΔ͍ͷҧ͍ DVSSFOU@BEBQUFS
rails/rails#29370
WTOJM
Ξμϓλͷࢦఆͱ 3BJMTΛىಈ࣌ͷ ৼΔ͍ʹ͍ͭͯ
w ͝ଘEBUBCBTFZNMʹࢦఆ͢Δ BEBQUFSͱԿͳͷ͔͍·Ұ $POOFDUJPO"EBQUFSͷબ development: adapter: mysql2 development: adapter: postgresql
development: adapter: sqlite3 development: adapter: oracle_enhanced
w EBUBCBTFZNMͰࢦఆͨ͠Ξμϓλ͕ SBJMTDSBJMTTͰཁٻ͞ΕΔἬͷྲྀΕ "33BJMUJFJOJUJBMJ[FS "3$POOFDUJPO)BOEMJOHFTUBCMJTI@DPOOFDUJ PO "3$POOFDUJPO"EBQUFST$POOFDUJPO4QFDJpD BUJPOTQFD FTUBCMJTI@DPOOFDUJPO
"33BJMUJFJOJUJBMJ[FS IUUQTHJUIVCDPNSBJMTSBJMTCMPCWSDBDUJWFSFDPSEMJCBDUJWF@SFDPSESBJMUJFSC-
"3$POOFDUJPO)BOEMJOH FTUBCMJTI@DPOOFDUJPO IUUQTHJUIVCDPNSBJMTSBJMTCMPCWSDBDUJWFSFDPSEMJCBDUJWF@SFDPSEDPOOFDUJPO@IBOEMJOHSC-
"3$POOFDUJPO"EBQUFST $POOFDUJPO4QFDJpDBUJPOTQFD IUUQTHJUIVCDPNSBJMTSBJMTCMPCWSDBDUJWFSFDPSEMJCBDUJWF@SFDPSEDPOOFDUJPO@BEBQUFSTDPOOFDUJPO@TQFDJpDBUJPOSC-
w EBUBCBTFZNMͷࢦఆBEBQUFS ΛݩʹΞμϓλΛSFRVJSF͢Δ "3$POOFDUJPO"EBQUFST $POOFDUJPO4QFDJpDBUJPOTQFD path_to_adapter = "active_record/connection_adapters/#{spec[:adapter]}_adapter" begin require
path_to_adapter rescue LoadError => e (snip) end (snip) adapter_method = "#{spec[:adapter]}_connection" IUUQTHJUIVCDPNSBJMTSBJMTCMPCWSDBDUJWFSFDPSEMJCBDUJWF@SFDPSEDPOOFDUJPO@BEBQUFSTDPOOFDUJPO@TQFDJpDBUJPOSC-- SFRVJSF
SFRVJSF͞ΕΔ$PSFBEBQUFST
w EBUBCBTFZNMͷࢦఆBEBQUFS ΛݩʹίωΫγϣϯϝιου໊Λܾఆ "3$POOFDUJPO"EBQUFST $POOFDUJPO4QFDJpDBUJPOTQFD path_to_adapter = "active_record/connection_adapters/#{spec[:adapter]}_adapter" begin require
path_to_adapter rescue LoadError => e (snip) end (snip) adapter_method = "#{spec[:adapter]}_connection" IUUQTHJUIVCDPNSBJMTSBJMTCMPCWSDBDUJWFSFDPSEMJCBDUJWF@SFDPSEDPOOFDUJPO@BEBQUFSTDPOOFDUJPO@TQFDJpDBUJPOSC-- @DPOOFDUJPO
IUUQTHJUIVCDPNSBJMTSBJMTCMPCWSDBDUJWFSFDPSEMJCBDUJWF@SFDPSEDPOOFDUJPO@BEBQUFSTNZTRM@BEBQUFSSC- @DPOOFDUJPO
IUUQTHJUIVCDPNSBJMTSBJMTCMPCWSDBDUJWFSFDPSEMJCBDUJWF@SFDPSEDPOOFDUJPO@BEBQUFSTNZTRM@BEBQUFSSC- @DPOOFDUJPO %#$MJFOU
w 3VCZΦϒδΣΫτܦ༝Ͱ.Z42-Λૢ࡞͢Δ ΫϥΠΞϯτͱͳΔυϥΠό(FN require "mysql2" client = Mysql2::Client.new( :host =>
"localhost", :username => "root" ) results = client.query( "SELECT * FROM users WHERE group=‘githubbers'" ) results.each do |row| puts row["id"] # row[“id”].is_a? Integer if row["dne"] # non-existant hash entry is nil puts row["dne"] end end .ZTRMHFN IUUQTHJUIVCDPNCSJBONBSJPNZTRMVTBHF
"3ϞσϧͱυϥΠόͷதؒ $POOFDUJPO"EBQUFST "CTUSBDU"EBQUFS $POOFDUJPO "EBQUFST-BZFS "3.PEFM -BZFS %BUBCBTF $MJFOU-BZFS ˞ਤྫ.Z42-Ξμϓλ
(FNpMFʹࢦఆ ͍ͯ͠Δͷ͜Ε $POOFDUJPO"EBQUFST "CTUSBDU.ZTRM"EBQUFS $POOFDUJPO"EBQUFST .ZTRM"EBQUFS HFN NZTRM .Z42- %BUBCBTF -BZFS "3
"3ϞσϧͱυϥΠόͷதؒ $POOFDUJPO "EBQUFST-BZFS "3.PEFM -BZFS %BUBCBTF $MJFOU-BZFS ˞ਤྫ1PTUHSF42-Ξμϓλ (FNpMFʹࢦఆ ͍ͯ͠Δͷ͜Ε
$POOFDUJPO"EBQUFST 1PTUHSF42-"EBQUFS HFN QH 1PTUHSF42- %BUBCBTF -BZFS $POOFDUJPO"EBQUFST "CTUSBDU"EBQUFS "3
"3ϞσϧͱυϥΠόͷதؒ $POOFDUJPO "EBQUFST-BZFS "3.PEFM -BZFS %BUBCBTF $MJFOU-BZFS ˞ਤྫ42-JUFΞμϓλ (FNpMFʹࢦఆ ͍ͯ͠Δͷ͜Ε
$POOFDUJPO"EBQUFST 42-JUF"EBQUFS HFN TRMJUF 42-JUF %BUBCBTF -BZFS $POOFDUJPO"EBQUFST "CTUSBDU"EBQUFS "3
w EBUBCBTFZNMʹج͍ͮͨ $POOFDUJPO"EBQUFSTΛ͏ w $POOFDUJPO"EBQUFSͷઌͷଓ σʔλϕʔευϥΠόHFNͱͳΔ w NZTRM QH TRMJUFͳͲ
"3ͷσʔλϕʔεଓͷߏ
w SBJMTSBJMTϦϙδτϦͰϝϯςφ ϯε͞Ε͍ͯΔΞμϓλΛࢦ͢ w ݱࡏ.Z42- NZTRM 1PTUHSF42-42-JUFͷͭ w 3BJMTͷ$*ϚτϦοΫεʹೖͬͯΔ
$PSFBEBQUFST
w ֎෦(FNͱͯ͠ཁٻ͞ΕΔΞμϓλ w 0SBDMF w 42-4FSWFS w 'JSFCJSE w FUD
FUD SEQBSUZBEBQUFST
w 3BJMTຊମʹόϯυϧ͞Ε͍ͯΔίΞ ΞμϓλҎ֎͜͜ͰSFRVJSFͯ͠Δ "3$POOFDUJPO"EBQUFST $POOFDUJPO4QFDJpDBUJPOTQFD path_to_adapter = "active_record/connection_adapters/#{spec[:adapter]}_adapter" begin require
path_to_adapter rescue LoadError => e (snip) end (snip) adapter_method = "#{spec[:adapter]}_connection" IUUQTHJUIVCDPNSBJMTSBJMTCMPCWSDBDUJWFSFDPSEMJCBDUJWF@SFDPSEDPOOFDUJPO@BEBQUFSTDPOOFDUJPO@TQ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λࢦఆ KBS PKECDKBS $POOFDUJPO"EBQUFST "CTUSBDU"EBQUFS "3
w KSVCZBDUJWFSFDPSEKECDBEBQUFS Ͱཧ͞Ε͍ͯΔ <ิ>0SBDMFҎ֎ͷ+%#$αϙʔτ
A development of Oracle enhanced adapter
w */%&9ʹؔ͢Δ5"#-&41"$&Λࢦఆ Ͱ͖ΔΑ͏ʹରԠͨ͠<> w SBJMTECTDIFNBMPBEͷϚϧνΠϯ αʔτʹରԠͨ͠<> w 3VCZ0$*Λ3VCZͷ #JH%FDJNBMରԠ<SVCZPDJ> ࢥ͍ग़ͷύονબ
w */%&9ʹؔ͢Δ5"#-&41"$&Λࢦఆ Ͱ͖ΔΑ͏ʹରԠͨ͠<> w SBJMTECTDIFNBMPBEͷϚϧνΠϯ αʔτʹରԠͨ͠<> w 3VCZ0$*Λ3VCZͷ #JH%FDJNBMରԠ<SVCZPDJ> ͡ΊͯͷΞμϓλύον
rsim/oracle-enhanced#1028
w 0SBDMFͰ5"#-&41"$&Ͱςʔϒϧ ΠϯσοΫεͷอଘྖҬࢦఆ͕Ͱ͖Δ w 0SBDMFFOBIBODFEBEBQUFSͰ EFGBVMU@UBCMFTQBDFTͰࢦఆՄೳ w QSJNBSZLFZʹରͯ͠͏·͘ޮ͔ͳ ͔ͬͨͷͰͨ͠ 5"#-&41"$&ͷࢦఆ
w ࣌ࣗ৴͕ͳ͘*TTVFͰ͓͍ खݩʹϞϯΩʔύον͋ͬͨ
w 54@*/%&9Ͱͳ͘54@%"5"ʹೖͬͯͨ ͷमਖ਼ύον 0QFOB13
"3.JHSBUJPOͷDSBFUF@UBCMFͷ SEQBSUZΞμϓλ࣮ͷมߋ தུ Ճ IUUQTHJUIVCDPNSTJNPSBDMFFOIBODFECMPCWSDMJCBDUJWF@SFDPSEDPOOFDUJPO@BEBQUFSTPSBDMF@FOIBODFETDIFNB@TUBUFNFOUTSC-
w "-5&3*/%&93*-%5"#-&41"$&Λ ࣮ߦ͢ΔϝιουΛఆ͍ٛͯ͠Δ ADSFBUF@UBCMFA͔ΒͷϑοΫ
w ϦϙδτϦΛԣஅͨ͠มߋ͕ඞཁͩͬͨ $*͕ͱ͓Βͳ͍
w 64&34Ͱͳ͘4:45&.ʹอଘ͞Εͯͨ w %&'"6-55"#-&41"$&ͷมߋ w 0SBDMF͚ͷSBJMTEFWCPYͷ13 ZBIPOEBSBJMTEFWCPY
w 3%#.4ͷΞμϓλ։ൃͳͷͰ 3%#.4ʹԠͨ͡։ൃڥΛඋ͢Δ ඞཁ͕͋Δ w ZBIPOEBSBJMTEFWCPY͕ 0SBDMF͚ͷ։ൃڥͱͳΔ w $*ͱ߹Θͤͯ͜ͷڥΛ͏ͷ͕ྑ͍ ։ൃڥͷݟΛಘΔ
Oracle with Rails 6.0
w 3BJMTҎલϓϥΠϚϦΩʔ*%ͷ ࠾൪ʹ͍ͭͯ4&26&/$&Ͱ͍ग़͞ Ε͍ͯΔ w 3BJMTҎ߱0SBDMFDͷ *EFOUJUZ$PMVNOΛ͏ํͰݕ౼ w OFYUWBMͱ͍͏1P$ͷϦϒʔτ 1P$*EFOUJUZ
w 3BJMTҎલͷσϑΥϧτ EFGBVMU@TFRVFODF@TUBSU@WBMVF w 3BJMTҎޙͷσϑΥϧτ EFGBVMU@TFRVFODF@TUBSU@WBMVF ʹͳΓଞͷΞμϓλͱಉ͡ڍಈʹ $IBOHFAEFGBVMU@TFRVFODF@TUBSU@WBMVFA GSPNUP
w SBJMTECTUSVDUVSFEVNQͷࡍ ʹσϑΥϧτͰ7*&8͕μϯϓ͞Ε ΔΑ͏ʹͳΔ &YUSBDUWJFXTUPEC TUSVDUVSFTRMCZEFGBVMU
w 0SBDMF%"5"#"4&-*/,ͱ͍͏ ଞͷ%#ͷσʔλΛҾ͘ػߏ͕͋Γ 3BJMTܥ0SBDMFΞμϓλἬαϙʔτ w 3BJMTҎޙ3BJMTͷෳ%#ର ԠʹͤΔ͜ͱʹͳΓػೳআ͢Δํ SBJMTSBJMTࢀর %SPQEBUBCBTFMJOLTVQQPSU
%SPQEBUBCBTFMJOLTVQQPSU
w "3#BTFDPOOFDUJPOUBCMFTͷ ΓʹؚΊͯΔϚςϏϡʔΛ֎͠ςʔ ϒϧͷΈฦ͢Α͏ʹ͢Δ͔Ͳ͏͔ʁ w 1PTUHSF42-Ξμϓλʹ͓͚Δಉϝ ιου͕ϚςϏϡʔΛฦ͔͢Ͳ͏͔ʹ ΑΔ (JU)VCίϝϯτௐ &YDMVEFANBUFSJBMJ[FE@WJFXTA
GSPNAUBCMFTA
w 0SBDMFD3ҎԼͰΧϥϜ໊ͳ ͲࣝผࢠʹόΠτҎԼͷ੍ݶ͕͋Δ w SBJMTSBJMTͷ"3ͷҰ෦ͷςετ͕ 0SBDMFͰམͪΔ͍ͪཁҼͰ͋Δ w 0SBDMFD3Ҏ্όΠτ ·Ͱͷ֦ு͞ΕΔ͚ͲͲ͏͢Δʁ -POHJEFOUJpFSTTVQQPSU
+3VCZ +%#$TVQQPSUT0SBDMFD PSIJHIFS1%# 1MVHHBCMFEBUBCBTF
Oracle enhanced 6.0 may require Oracle 12c or higher
w ਓྨͰݟ͍ͯΔਓ͕ݶΒΕ͍ͯΔͱ͍͏ $POOFDUJPO"EBQUFSTͷׂͱߏͱ ϦϙδτϦͰͷॴʹ͍ͭͯ͠·ͨ͠ w "SFMपล͍͠ͷͰׂѪ͍ͯ͠·͕͢ɺ ͜ͷ͋ͨΓ৮ΕΔͱ͔ͳΓڧ͍ͱࢥ͍·͢ w LBNJQP͞ΜͱZBIPOEB͞Μ͍͢͝ਓ ͓ΘΓʹ
None