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

DBFlute bridges between DB and App

Sponsored · Ship Features Fearlessly Turn features on and off without deploys. Used by thousands of Ruby developers.
Avatar for jflute jflute
October 17, 2015

DBFlute bridges between DB and App

at JPOUG> SET EVENTS 20151017

Avatar for jflute

jflute

October 17, 2015
Tweet

More Decks by jflute

Other Decks in Programming

Transcript

  1. フレームワークあるある getMemberStatus() された時に検索 List<Member> memberList = …(最初の検索) for (Member member

    : memberList) { member.getMemberStatus() // ひぃぃぃー } getされた時に関連テーブルのデータを検索 いわゆる LazyLoad 機能 30 ギャップその4:アプリがぐるぐる回す
  2. SQLの発行回数をログに …(σόοάϩάͷத) [request] lastaflute.dbflute.SQL_COUNT=
 {total=2, selectCB=2, entityUpdate=0 , queryUpdate=0, outsideSql=0,

    procedure=0} … ※DBFluteͱ࿈ܞͨ͠WebϑϨʔϜϫʔΫ
 ʮLastaFluteʯʹͯ 32 ギャップその4:アプリがぐるぐる回す
  3. 発行しすぎ警告ログ …(ܯࠂϩάͷத) *Too many SQL executions:
 {total=81, selectCB=3, entityUpdate=78, queryUpdate=0,

    outsideSql=0, procedure=0}
 ɹin ProductListAction.search() … ※DBFluteͱ࿈ܞͨ͠WebϑϨʔϜϫʔΫ
 ʮLastaFluteʯʹͯ 33 ギャップその4:アプリがぐるぐる回す
  4. アプリ, DBAあるある 落ちた ↓ 調べる ↓ 本番DB違う 37 Alter書いた ↓

    Index書き忘れた ↓ 実行し忘れた ギャップその5:本番とスキーマちっがーう
  5. AlterCheckの流れ 1. 前のDB (フルDDL) を保存 by DBFlute 2. 普通にDB変更 by

    ERD 3. Alter文を書く by 人類 4. フルDDLを吐き出して… by ERD 5. 方程式と合わせる by DBFlute 41 ギャップその5:本番とスキーマちっがーう
  6. DBFluteはSQLを大切に4 EntityのSetter呼び出し情報でupdate文を構築 (無駄な事前検索や問答無用全カラム更新しない) Member mb = new Member(); mb.setMemberId(3); mb.setMemberName(“jflute”);

    memberBhv.update(mb); ↓↓↓ update MEMBER set MEMBER_NAME = ‘jflute’ where MEMBER_ID = 3 47 ギャップその6:パフォーマンス考慮たのむよー