SlideShare a Scribd company logo
1 of 36
Download to read offline
Ian - 20.11.2020
ORM(Object Relational Mapper)
Migration & N+1 Problem
• 

• 

• TypeORM 

• TypeORM vs. Sequelize

• ORM 

• N+1 

• & 

• TypeORM vs. Sequelize

• ORM
TOC
Migration
Sequelize ?
git vcs
migration . migration
, . migration
. Migration (up),
(down) .
Migration
• sequelize orm 

• orm models, migrations, seeders 

• model, migration
ORM ??
Migration
• up, down


• ?
?

•
migration !
Src/models/department.js
Src/migrations/timestamp-department.js
Migration
• 

• People.city country
Migration
• sequelize, typeorm 

• if (isSync) 

• city country !
Migration
• ? country
Migration
• 

• !
Migration
• 

•
Migration
• ,

• synchronize
!

• association


• migration
Migration
• config .. ..

• https://github.com/Yangeok/Today-I-learned/blob/master/
getting_ready_posting/2020-11-18-typeorm-theoritical.md

• Migration:create, migration:generate, migration:run, migration:revert 4
!
Migration
: Migration:create
• Migration 

• Create
Migration
: Migration:generate
• Migration 

• generate !
Migration
: Migration:run
• Migartion 

• Migration up 

• ( ) up migrations 

•
Migration
: Migration:revert
• 

• Migration down 

• (LIFO) 

• Migrations row 

• Migration:revert:all typeorm
Migration
TypeORM vs. Sequelize: migration
• Sequelize

• Entity Migration 

• Migration:generate typeorm migration:create 

• Migration:undo:all 

• typeorm

• Entity migration migration:generate 

• schema:sync 

• Migration:revert migration
Migration
TypeORM vs. Sequelize: seeding
• Sequelize

• typeorm
Migration
TypeORM vs. Sequelize
• Sequelize

• migration:undo:all migration . 

• seeding cli up, down .

• Typeorm

• migration . 

• cli synchronize .
Migration
ORM : Doctrine (PHP)
• migration . 

• sequelize umzug migration hook cli .
Migration
ORM : Active record (Ruby)
• typeorm active record . 

• migration . 

• timestamp YYYYMMDDHHMMSS . ( :
20201120120000_test-migration-create.rb)
N+1
&
• orm 

• 2 , 1 N
N+1 

• Orm 

• N+1 raw sql
N+1
&
• People Companies 

• Companies People 1:M !
N+1
&
• Select
!
N+1
&
• People Companies.department 

• ! 6(1+5) <- N+1
N+1
&
• join N+1 !

• People
N+1
& : Eager loading
• join
!
N+1
& : Eager loading
• 

• 

• 

• , 

• 

• Orders OrderDetails, Delivery ,
n+1 eager loading
N+1
& : Lazy loading
• join n+1 lazy loading
N+1
& : Lazy loading
• 

• ( db ..)

• cpu 

• …

• 

• sns 

• Eager loading 

• Lazy loading !
N+1 Problem
TypeORM vs. Sequelize
• typeorm eager loading . (Optional /
eager loading)

• lazy loading Promise generic type 

• .
Eager loading Lazy loading
N+1 Problem
TypeORM vs. Sequelize
• sequelize find  Include eager loading
. ( lazy loading)

• join . lazy loading
include .
Eager loading
lazy loading
N+1 Problem
ORM : CakeORM (PHP)
• eager loading . contain .

• lazy loading .
N+1 Problem
ORM : JPA (Java)
• eager loading . FetchType.EAGER
.

• lazy loading . FetchType.LAZY
.
N+1 Problem
ORM : Active record (Ruby)
• eager loading . sequelize includes
.

• lazy loading .
EOF
,

More Related Content

Similar to TypeORM으로 보는 마이그레이션과 N+1 문제

Killing Shark-Riding Dinosaurs with ORM
Killing Shark-Riding Dinosaurs with ORMKilling Shark-Riding Dinosaurs with ORM
Killing Shark-Riding Dinosaurs with ORMOrtus Solutions, Corp
 
The Weather of the Century
The Weather of the CenturyThe Weather of the Century
The Weather of the CenturyMongoDB
 
Nu Skin: Integrating the Day CMS with Translation.com
Nu Skin: Integrating the Day CMS with Translation.comNu Skin: Integrating the Day CMS with Translation.com
Nu Skin: Integrating the Day CMS with Translation.comDay Software
 
Real time collaborative text editing, by Miroslav Hettes, Smarkup
Real time collaborative text editing, by Miroslav Hettes, SmarkupReal time collaborative text editing, by Miroslav Hettes, Smarkup
Real time collaborative text editing, by Miroslav Hettes, SmarkupSmarkup
 
Reactive Xamarin. UA Mobile 2016.
Reactive Xamarin. UA Mobile 2016.Reactive Xamarin. UA Mobile 2016.
Reactive Xamarin. UA Mobile 2016.UA Mobile
 
Atlas Hugged: How Atlassian Tools Enabled a Software Internalization Team
Atlas Hugged: How Atlassian Tools Enabled a Software Internalization TeamAtlas Hugged: How Atlassian Tools Enabled a Software Internalization Team
Atlas Hugged: How Atlassian Tools Enabled a Software Internalization TeamAtlassian
 
Atlas Hugged: How Atlassian Tools Enabled a Software Internalization Team
Atlas Hugged: How Atlassian Tools Enabled a Software Internalization TeamAtlas Hugged: How Atlassian Tools Enabled a Software Internalization Team
Atlas Hugged: How Atlassian Tools Enabled a Software Internalization TeamAtlassian
 
Python教程 / Python tutorial
Python教程 / Python tutorialPython教程 / Python tutorial
Python教程 / Python tutorialee0703
 
從零開始的爬蟲之旅 Crawler from zero
從零開始的爬蟲之旅 Crawler from zero從零開始的爬蟲之旅 Crawler from zero
從零開始的爬蟲之旅 Crawler from zeroShi-Ken Don
 
플렉스팀 프론트엔드 기술 스택의 이해: `lint`, `build`, `run`
플렉스팀 프론트엔드 기술 스택의 이해: `lint`, `build`, `run`플렉스팀 프론트엔드 기술 스택의 이해: `lint`, `build`, `run`
플렉스팀 프론트엔드 기술 스택의 이해: `lint`, `build`, `run`Heejong Ahn
 
MongoDB In Production At Sailthru
MongoDB In Production At SailthruMongoDB In Production At Sailthru
MongoDB In Production At Sailthruibwhite
 
Cross-Platform Desktop Apps with Electron (CodeStock Edition)
Cross-Platform Desktop Apps with Electron (CodeStock Edition)Cross-Platform Desktop Apps with Electron (CodeStock Edition)
Cross-Platform Desktop Apps with Electron (CodeStock Edition)David Neal
 
GO programming language
GO programming languageGO programming language
GO programming languagetung vu
 
Dynamic Sound for iOS Apps and Games
Dynamic Sound for iOS Apps and GamesDynamic Sound for iOS Apps and Games
Dynamic Sound for iOS Apps and GamesTack Mobile
 
Trending with Purpose
Trending with PurposeTrending with Purpose
Trending with PurposeJason Dixon
 
分散型Stablecoin "Dai" の仕組み
分散型Stablecoin "Dai" の仕組み分散型Stablecoin "Dai" の仕組み
分散型Stablecoin "Dai" の仕組みHiro Inagaki
 

Similar to TypeORM으로 보는 마이그레이션과 N+1 문제 (20)

Killing Shark-Riding Dinosaurs with ORM
Killing Shark-Riding Dinosaurs with ORMKilling Shark-Riding Dinosaurs with ORM
Killing Shark-Riding Dinosaurs with ORM
 
The Weather of the Century
The Weather of the CenturyThe Weather of the Century
The Weather of the Century
 
Nu Skin: Integrating the Day CMS with Translation.com
Nu Skin: Integrating the Day CMS with Translation.comNu Skin: Integrating the Day CMS with Translation.com
Nu Skin: Integrating the Day CMS with Translation.com
 
Rupher = Ruby + Gopther
Rupher = Ruby + GoptherRupher = Ruby + Gopther
Rupher = Ruby + Gopther
 
Rupher
RupherRupher
Rupher
 
Real time collaborative text editing, by Miroslav Hettes, Smarkup
Real time collaborative text editing, by Miroslav Hettes, SmarkupReal time collaborative text editing, by Miroslav Hettes, Smarkup
Real time collaborative text editing, by Miroslav Hettes, Smarkup
 
Reactive Xamarin. UA Mobile 2016.
Reactive Xamarin. UA Mobile 2016.Reactive Xamarin. UA Mobile 2016.
Reactive Xamarin. UA Mobile 2016.
 
Atlas Hugged: How Atlassian Tools Enabled a Software Internalization Team
Atlas Hugged: How Atlassian Tools Enabled a Software Internalization TeamAtlas Hugged: How Atlassian Tools Enabled a Software Internalization Team
Atlas Hugged: How Atlassian Tools Enabled a Software Internalization Team
 
Atlas Hugged: How Atlassian Tools Enabled a Software Internalization Team
Atlas Hugged: How Atlassian Tools Enabled a Software Internalization TeamAtlas Hugged: How Atlassian Tools Enabled a Software Internalization Team
Atlas Hugged: How Atlassian Tools Enabled a Software Internalization Team
 
Python教程 / Python tutorial
Python教程 / Python tutorialPython教程 / Python tutorial
Python教程 / Python tutorial
 
從零開始的爬蟲之旅 Crawler from zero
從零開始的爬蟲之旅 Crawler from zero從零開始的爬蟲之旅 Crawler from zero
從零開始的爬蟲之旅 Crawler from zero
 
ORM Pink Unicorns
ORM Pink UnicornsORM Pink Unicorns
ORM Pink Unicorns
 
플렉스팀 프론트엔드 기술 스택의 이해: `lint`, `build`, `run`
플렉스팀 프론트엔드 기술 스택의 이해: `lint`, `build`, `run`플렉스팀 프론트엔드 기술 스택의 이해: `lint`, `build`, `run`
플렉스팀 프론트엔드 기술 스택의 이해: `lint`, `build`, `run`
 
MongoDB In Production At Sailthru
MongoDB In Production At SailthruMongoDB In Production At Sailthru
MongoDB In Production At Sailthru
 
Pairjour
PairjourPairjour
Pairjour
 
Cross-Platform Desktop Apps with Electron (CodeStock Edition)
Cross-Platform Desktop Apps with Electron (CodeStock Edition)Cross-Platform Desktop Apps with Electron (CodeStock Edition)
Cross-Platform Desktop Apps with Electron (CodeStock Edition)
 
GO programming language
GO programming languageGO programming language
GO programming language
 
Dynamic Sound for iOS Apps and Games
Dynamic Sound for iOS Apps and GamesDynamic Sound for iOS Apps and Games
Dynamic Sound for iOS Apps and Games
 
Trending with Purpose
Trending with PurposeTrending with Purpose
Trending with Purpose
 
分散型Stablecoin "Dai" の仕組み
分散型Stablecoin "Dai" の仕組み分散型Stablecoin "Dai" の仕組み
分散型Stablecoin "Dai" の仕組み
 

Recently uploaded

ROBOETHICS-CCS345 ETHICS AND ARTIFICIAL INTELLIGENCE.ppt
ROBOETHICS-CCS345 ETHICS AND ARTIFICIAL INTELLIGENCE.pptROBOETHICS-CCS345 ETHICS AND ARTIFICIAL INTELLIGENCE.ppt
ROBOETHICS-CCS345 ETHICS AND ARTIFICIAL INTELLIGENCE.pptJohnWilliam111370
 
Paper Tube : Shigeru Ban projects and Case Study of Cardboard Cathedral .pdf
Paper Tube : Shigeru Ban projects and Case Study of Cardboard Cathedral .pdfPaper Tube : Shigeru Ban projects and Case Study of Cardboard Cathedral .pdf
Paper Tube : Shigeru Ban projects and Case Study of Cardboard Cathedral .pdfNainaShrivastava14
 
Python Programming for basic beginners.pptx
Python Programming for basic beginners.pptxPython Programming for basic beginners.pptx
Python Programming for basic beginners.pptxmohitesoham12
 
Robotics Group 10 (Control Schemes) cse.pdf
Robotics Group 10  (Control Schemes) cse.pdfRobotics Group 10  (Control Schemes) cse.pdf
Robotics Group 10 (Control Schemes) cse.pdfsahilsajad201
 
Cost estimation approach: FP to COCOMO scenario based question
Cost estimation approach: FP to COCOMO scenario based questionCost estimation approach: FP to COCOMO scenario based question
Cost estimation approach: FP to COCOMO scenario based questionSneha Padhiar
 
Main Memory Management in Operating System
Main Memory Management in Operating SystemMain Memory Management in Operating System
Main Memory Management in Operating SystemRashmi Bhat
 
"Exploring the Essential Functions and Design Considerations of Spillways in ...
"Exploring the Essential Functions and Design Considerations of Spillways in ..."Exploring the Essential Functions and Design Considerations of Spillways in ...
"Exploring the Essential Functions and Design Considerations of Spillways in ...Erbil Polytechnic University
 
Research Methodology for Engineering pdf
Research Methodology for Engineering pdfResearch Methodology for Engineering pdf
Research Methodology for Engineering pdfCaalaaAbdulkerim
 
Ch10-Global Supply Chain - Cadena de Suministro.pdf
Ch10-Global Supply Chain - Cadena de Suministro.pdfCh10-Global Supply Chain - Cadena de Suministro.pdf
Ch10-Global Supply Chain - Cadena de Suministro.pdfChristianCDAM
 
THE SENDAI FRAMEWORK FOR DISASTER RISK REDUCTION
THE SENDAI FRAMEWORK FOR DISASTER RISK REDUCTIONTHE SENDAI FRAMEWORK FOR DISASTER RISK REDUCTION
THE SENDAI FRAMEWORK FOR DISASTER RISK REDUCTIONjhunlian
 
Mine Environment II Lab_MI10448MI__________.pptx
Mine Environment II Lab_MI10448MI__________.pptxMine Environment II Lab_MI10448MI__________.pptx
Mine Environment II Lab_MI10448MI__________.pptxRomil Mishra
 
System Simulation and Modelling with types and Event Scheduling
System Simulation and Modelling with types and Event SchedulingSystem Simulation and Modelling with types and Event Scheduling
System Simulation and Modelling with types and Event SchedulingBootNeck1
 
11. Properties of Liquid Fuels in Energy Engineering.pdf
11. Properties of Liquid Fuels in Energy Engineering.pdf11. Properties of Liquid Fuels in Energy Engineering.pdf
11. Properties of Liquid Fuels in Energy Engineering.pdfHafizMudaserAhmad
 
US Department of Education FAFSA Week of Action
US Department of Education FAFSA Week of ActionUS Department of Education FAFSA Week of Action
US Department of Education FAFSA Week of ActionMebane Rash
 
Module-1-(Building Acoustics) Noise Control (Unit-3). pdf
Module-1-(Building Acoustics) Noise Control (Unit-3). pdfModule-1-(Building Acoustics) Noise Control (Unit-3). pdf
Module-1-(Building Acoustics) Noise Control (Unit-3). pdfManish Kumar
 
Immutable Image-Based Operating Systems - EW2024.pdf
Immutable Image-Based Operating Systems - EW2024.pdfImmutable Image-Based Operating Systems - EW2024.pdf
Immutable Image-Based Operating Systems - EW2024.pdfDrew Moseley
 
TEST CASE GENERATION GENERATION BLOCK BOX APPROACH
TEST CASE GENERATION GENERATION BLOCK BOX APPROACHTEST CASE GENERATION GENERATION BLOCK BOX APPROACH
TEST CASE GENERATION GENERATION BLOCK BOX APPROACHSneha Padhiar
 
『澳洲文凭』买麦考瑞大学毕业证书成绩单办理澳洲Macquarie文凭学位证书
『澳洲文凭』买麦考瑞大学毕业证书成绩单办理澳洲Macquarie文凭学位证书『澳洲文凭』买麦考瑞大学毕业证书成绩单办理澳洲Macquarie文凭学位证书
『澳洲文凭』买麦考瑞大学毕业证书成绩单办理澳洲Macquarie文凭学位证书rnrncn29
 
Artificial Intelligence in Power System overview
Artificial Intelligence in Power System overviewArtificial Intelligence in Power System overview
Artificial Intelligence in Power System overviewsandhya757531
 

Recently uploaded (20)

ROBOETHICS-CCS345 ETHICS AND ARTIFICIAL INTELLIGENCE.ppt
ROBOETHICS-CCS345 ETHICS AND ARTIFICIAL INTELLIGENCE.pptROBOETHICS-CCS345 ETHICS AND ARTIFICIAL INTELLIGENCE.ppt
ROBOETHICS-CCS345 ETHICS AND ARTIFICIAL INTELLIGENCE.ppt
 
Paper Tube : Shigeru Ban projects and Case Study of Cardboard Cathedral .pdf
Paper Tube : Shigeru Ban projects and Case Study of Cardboard Cathedral .pdfPaper Tube : Shigeru Ban projects and Case Study of Cardboard Cathedral .pdf
Paper Tube : Shigeru Ban projects and Case Study of Cardboard Cathedral .pdf
 
Python Programming for basic beginners.pptx
Python Programming for basic beginners.pptxPython Programming for basic beginners.pptx
Python Programming for basic beginners.pptx
 
Robotics Group 10 (Control Schemes) cse.pdf
Robotics Group 10  (Control Schemes) cse.pdfRobotics Group 10  (Control Schemes) cse.pdf
Robotics Group 10 (Control Schemes) cse.pdf
 
Cost estimation approach: FP to COCOMO scenario based question
Cost estimation approach: FP to COCOMO scenario based questionCost estimation approach: FP to COCOMO scenario based question
Cost estimation approach: FP to COCOMO scenario based question
 
Main Memory Management in Operating System
Main Memory Management in Operating SystemMain Memory Management in Operating System
Main Memory Management in Operating System
 
"Exploring the Essential Functions and Design Considerations of Spillways in ...
"Exploring the Essential Functions and Design Considerations of Spillways in ..."Exploring the Essential Functions and Design Considerations of Spillways in ...
"Exploring the Essential Functions and Design Considerations of Spillways in ...
 
Designing pile caps according to ACI 318-19.pptx
Designing pile caps according to ACI 318-19.pptxDesigning pile caps according to ACI 318-19.pptx
Designing pile caps according to ACI 318-19.pptx
 
Research Methodology for Engineering pdf
Research Methodology for Engineering pdfResearch Methodology for Engineering pdf
Research Methodology for Engineering pdf
 
Ch10-Global Supply Chain - Cadena de Suministro.pdf
Ch10-Global Supply Chain - Cadena de Suministro.pdfCh10-Global Supply Chain - Cadena de Suministro.pdf
Ch10-Global Supply Chain - Cadena de Suministro.pdf
 
THE SENDAI FRAMEWORK FOR DISASTER RISK REDUCTION
THE SENDAI FRAMEWORK FOR DISASTER RISK REDUCTIONTHE SENDAI FRAMEWORK FOR DISASTER RISK REDUCTION
THE SENDAI FRAMEWORK FOR DISASTER RISK REDUCTION
 
Mine Environment II Lab_MI10448MI__________.pptx
Mine Environment II Lab_MI10448MI__________.pptxMine Environment II Lab_MI10448MI__________.pptx
Mine Environment II Lab_MI10448MI__________.pptx
 
System Simulation and Modelling with types and Event Scheduling
System Simulation and Modelling with types and Event SchedulingSystem Simulation and Modelling with types and Event Scheduling
System Simulation and Modelling with types and Event Scheduling
 
11. Properties of Liquid Fuels in Energy Engineering.pdf
11. Properties of Liquid Fuels in Energy Engineering.pdf11. Properties of Liquid Fuels in Energy Engineering.pdf
11. Properties of Liquid Fuels in Energy Engineering.pdf
 
US Department of Education FAFSA Week of Action
US Department of Education FAFSA Week of ActionUS Department of Education FAFSA Week of Action
US Department of Education FAFSA Week of Action
 
Module-1-(Building Acoustics) Noise Control (Unit-3). pdf
Module-1-(Building Acoustics) Noise Control (Unit-3). pdfModule-1-(Building Acoustics) Noise Control (Unit-3). pdf
Module-1-(Building Acoustics) Noise Control (Unit-3). pdf
 
Immutable Image-Based Operating Systems - EW2024.pdf
Immutable Image-Based Operating Systems - EW2024.pdfImmutable Image-Based Operating Systems - EW2024.pdf
Immutable Image-Based Operating Systems - EW2024.pdf
 
TEST CASE GENERATION GENERATION BLOCK BOX APPROACH
TEST CASE GENERATION GENERATION BLOCK BOX APPROACHTEST CASE GENERATION GENERATION BLOCK BOX APPROACH
TEST CASE GENERATION GENERATION BLOCK BOX APPROACH
 
『澳洲文凭』买麦考瑞大学毕业证书成绩单办理澳洲Macquarie文凭学位证书
『澳洲文凭』买麦考瑞大学毕业证书成绩单办理澳洲Macquarie文凭学位证书『澳洲文凭』买麦考瑞大学毕业证书成绩单办理澳洲Macquarie文凭学位证书
『澳洲文凭』买麦考瑞大学毕业证书成绩单办理澳洲Macquarie文凭学位证书
 
Artificial Intelligence in Power System overview
Artificial Intelligence in Power System overviewArtificial Intelligence in Power System overview
Artificial Intelligence in Power System overview
 

TypeORM으로 보는 마이그레이션과 N+1 문제