Server๐Ÿงค

[Server] Paging, Transaction

yujindonut 2022. 5. 18. 11:41
728x90

Paging 

๋ฐ์ดํ„ฐ๋ฅผ ์›ํ•˜๋Š” ๋งŒํผ ์ž˜๋ผ์„œ ๋ณผ ์ˆ˜ ์žˆ๊ฒŒ 

SELECT *
FROM User
LIMIT 0, 5;
// 0 ~ 4๋ฒˆ์งธ ์ธ๋ฑ์Šค์˜ ๋ฐ์ดํ„ฐ๋ฅผ ๊ฐ€์ ธ์˜ค๊ฒŒ ๋จ
ํŽ˜์ด์ง€ ๋ฒˆํ˜ธ(x) ๋ฐ์ดํ„ฐ (y) y = pageSize(page - 1)
y = 5(x - 1)
1 0,1,2,3,4 limit 0, 5 x = 1 , y = 0
2 5,6,7,8,9 limit 5, 10 x = 2, y = 5
3 10,11,12,13,14 limit 10, 15 x = 3, y = 10

Transaction

์˜ˆ ) ์ธ์Šคํƒ€๊ทธ๋žจ ์ƒ์„ฑ api 

์ดˆ๊ธฐ ์ƒํƒœ -> ๊ฒŒ์‹œ๋ฌผ ์ƒ์„ฑ -> ๊ฒŒ์‹œ๋ฌผ ์‚ฌ์ง„ ์ƒ์„ฑ -> ๋ฐ˜์˜์ƒํƒœ

๋งŒ์•ฝ ์ด์ค‘์— ํ•˜๋‚˜๋ผ๋„ ์ด๋ฃจ์–ด์ง€์ง€ ์•Š์œผ๋ฉด ์ดˆ๊ธฐ์ƒํƒœ๋กœ ๋Œ์•„๊ฐ

 

๋ฐ˜์˜ ( commit ) 

์› ์ƒํƒœ๋กœ ๋Œ์•„๊ฐ€๋Š” ๊ฒƒ ( rollback )

 

728x90