Upgrade to Pro — share decks privately, control downloads, hide ads and more …

YAPC::Tokyo 2019 Log Friendly DB Design

fisto
January 26, 2019

YAPC::Tokyo 2019 Log Friendly DB Design

ログにやさしいDB設計

fisto

January 26, 2019
Tweet

Other Decks in Programming

Transcript

  1. 2019.01.26 :"1$5PLZP 9 ϩά ͍Ζ͍Ζ͋Δ ΞΫηεϩά )551αʔό FYOHJOY BQBDIF ͷϩά

    ΞϓϦϩά 8FCΞϓϦέʔγϣϯ FY1FSM 1)1 3VCZ ͷϩά %#ϩά %# FY.Z42- 1PTUHSF42- ͷϩά
  2. 2019.01.26 :"1$5PLZP 20 Ϣʔβͷ೔ຊԁ࢒ߴͷઃܭᶃ VTFS JE 1,  VTFSOBNF 

    VTFS@CBMBODF VTFS@JE 1,  BNPVOU VQEBUFE@BU Ϣʔβͷ࢒ߴͷཤྺʢ࢒ߴͷਪҠʣΛ؅ཧը໘ʹද͍ࣔͨ͠ͱ͖ ˠ࢒ߴมߋʹؔΘΔΤϯυϙΠϯτ΁ͷΞΫηεϩάΛࢀর͢Δʁ
  3. 2019.01.26 :"1$5PLZP 21 Ϣʔβͷ೔ຊԁ࢒ߴͷઃܭᶄ VTFS JE 1,  VTFSOBNF 

    VTFS@CBMBODF JE 1,  VTFS@JE BNPVOU DSFBUFE@BU ߋ৽࣌͸มԽޙͷ৽͍͠࢒ߴΛ*/4&35ͯ͠ɺ࠷৽ͷ࢒ߴΛऔΔͱ͖͸ SELECT ~ WHERE user_id = hoge ORDER BY created_at LIMIT 1
  4. 2019.01.26 :"1$5PLZP 24 Ϣʔβ࢒ߴͷઃܭᶃ VTFS JE 1,  VTFSOBNF 

    VTFS@CBMBODF VTFS@JE 1,  KQZ@BNPVOU CUD@BNPVOU VQEBUFE@BU ߋ৽࣌͸৽͍͠࢒ߴͰ61%"5& ௨՟ͷछผ͕૿͑Δͨͼʹ"-5&3จΛଧͭͷ͔ʁʢଧͪͨ͘ͳ͍'ʣ
  5. 2019.01.26 :"1$5PLZP 25 Ϣʔβ࢒ߴͷઃܭᶄ VTFS JE 1,  VTFSOBNF 

    VTFS@CBMBODF VTFS@JE 1,  DVSSFODZ@JE BNPVOU VQEBUFE@BU ೔ຊԁ࢒ߴͷͱ͖ͱಉ༷ʹɺ Ϣʔβͷ࢒ߴͷཤྺʢ࢒ߴͷਪҠʣΛ؅ཧը໘ʹද͍ࣔͨ͠
  6. 2019.01.26 :"1$5PLZP 26 Ϣʔβ࢒ߴͷઃܭᶅ VTFS JE 1,  VTFSOBNF 

    VTFS@CBMBODF JE 1,  VTFS@JE DVSSFODZ@JE BNPVOU DSFBUFE@BU ߋ৽࣌͸มԽޙͷ৽͍͠࢒ߴΛ*/4&35 Ͱ͸ɺϢʔβͷ࠷৽ͷ࢒ߴΛऔΔͱ͖͸ʜʁ
  7. 2019.01.26 :"1$5PLZP 27 Ϣʔβ࢒ߴͷઃܭᶅ Ϣʔβͷ࠷৽ͷ࢒ߴΛ௨՟ࢦఆͰऔಘ͍ͨ͠ͱ͖ SELECT ~ WHERE user_id =

    hoge AND currency_id = jpy ORDER BY created_at LIMIT 1 Ϣʔβͷ࠷৽ͷ࢒ߴΛશ௨՟छผͰऔಘ͍ͨ͠ͱ͖ ˠΫΤϦͰ͍͘ͳΒαϒΫΤϦ஍ࠈ ˠ্ͷΫΤϦΛ௨՟छผ͝ͱʹ࣮ߦ
  8. 2019.01.26 :"1$5PLZP 28 Ϣʔβ࢒ߴͷઃܭᶆ VTFS JE 1,  VTFSOBNF 

    VTFS@CBMBODF VTFS@JE 1,  DVSSFODZ@JE 1,  BNPVOU VQEBUFE@BU VTFS@CBMBODFʹ61%"5&ͷΫΤϦΛ࣮ߦ͢Δͱ͖ VTFS@CBMBODF@MPHʹ΄΅ಉ౳ͷϨίʔυΛ*/4&35͢Δ VTFS@CBMBODF@MPH JE 1,  VTFS@JE DVSSFODZ@JE BNPVOU VQEBUFE@BU ෳ߹1,
  9. 2019.01.26 :"1$5PLZP 29 Ϣʔβ࢒ߴͷઃܭᶆ Ϣʔβͷ࠷৽ͷ࢒ߴΛ௨՟ࢦఆͰऔಘ͍ͨ͠ͱ͖ SELECT * FROM user_balance WHERE

    user_id = hoge AND currency_id = jpy Ϣʔβͷ࠷৽ͷ࢒ߴΛશ௨՟छผͰऔಘ͍ͨ͠ͱ͖ SELECT * FROM user_balance WHERE user_id = hoge ؅ཧը໘ͰཤྺΛऔಘ͍ͨ͠ͱ͖ʢ௨՟ࢦఆʣ SELECT * FROM user_balance_log WHERE user_id = hoge AND currency_id = jpy
  10. 2019.01.26 :"1$5PLZP 33 ϝΠϯςʔϒϧͷΧϥϜ໊ʹॏෳ͠ͳ໋໊͍ IPHF JE 1,  IPHF VQEBUFE@BU

    IPHF@MPH MPH@JE 1,  JE IPHF VQEBUFE@BU MPHHFE@BU ϩάςʔϒϧͷ໋໊نଇɺڞ௨ΧϥϜ໊͸౷ҰͰ͖ΔΑ͏ʹ
  11. 2019.01.26 :"1$5PLZP 34 Ϩίʔυ࡟আ΁ͷରԠ IPHF JE 1,  IPHF VQEBUFE@BU

    IPHF@MPH MPH@JE 1,  JE IPHF VQEBUFE@BU MPHHFE@BU IPHFͷϨίʔυΛ࡟আͨ͠ͱ͖IPHF@MPHʹͲΜͳϨίʔυ͕ೖΕ͹Α͍͔
  12. 2019.01.26 :"1$5PLZP 35 Ϩίʔυ࡟আϑϥάͷ௥Ճ IPHF JE 1,  IPHF VQEBUFE@BU

    JT@EFMFUFE IPHF@MPH MPH@JE 1,  JE IPHF VQEBUFE@BU MPHHFE@BU JT@EFMFUF@MPH ෺ཧ࡟আ૝ఆ͕ͩɺສ͕Ұͷ࿦ཧ࡟আʹ΋ରԠͰ͖ΔΑ͏ʹϑϥάΛ໋໊
  13. 2019.01.26 :"1$5PLZP 36 ϩάςʔϒϧͷ࠷ऴઃܭ IPHF JE 1,  IPHF VQEBUFE@BU

    IPHF@MPH MPH@JE 1,  JE IPHF VQEBUFE@BU MPHHFE@BU JT@EFMFUF@MPH