code-tree
@dltjdqls12007345
Reviews Written
8
Average Rating
5.0
Posts
Q&A
์ปค๋ฒ๋ง ์ธ๋ฑ์ค ์ง๋ฌธ ๋๋ฆฝ๋๋ค
๋ต๋ณ ๊ฐ์ฌํฉ๋๋ค! ์ฟผ๋ฆฌ๋ ๊ฐ์ด ๋ณด์ฌ๋๋ฆฌ๊ฒ ์ต๋๋ค์ฅ์์๋ ๋ฐฉ๋ช ๋ก์ ๋จ๊ธธ ์ ์๊ณ ๋ฐฉ๋ช ๋ก์ ํด๋น ์ฅ์์์ ์ฐ์ ์ฌ์ง๊ณผ ๊ธฐํ ์ ๋ณด๋ค์ด ์์ต๋๋ค. ๋ฐฉ๋ช ๋ก์ ์ญ์ , ๋น๊ณต๊ฐ๊ฐ ๊ฐ๋ฅํฉ๋๋ค- ์ฅ์(Spot) : ๋ฐฉ๋ช ๋ก(Post) = 1 : N- ๋ฐฉ๋ช ๋ก : ์ฌ์ง(Photo) = 1 : 1ํ์ด์ง ์ฟผ๋ฆฌ๋ ๋ค์๊ณผ ๊ฐ์ ํํ์ ๋๋คselect p.spot_id, p.id, p.user_id, ph.photo_url, p.is_private from post p join photo ph on ph.id = p.photo_id where p.spot_id = 1 and p.deleted_at is null and (p.is_private = false or p.user_id = 1) order by p.id desc limit 0, 10; ๋ค์ ์ฟผ๋ฆฌ๋ ํน์ ์ฅ์๋ณ๋ก ์ต์ ๋ฐฉ๋ช ๋ก ๋ฏธ๋ฆฌ๋ณด๊ธฐ n๊ฐ๋ฅผ ์กฐํํ๋ ์ฟผ๋ฆฌ์ ๋๋ค select s.id, spot_id, photo_url from spot s join lateral ( select p.id, spot_id, photo.photo_url from post p join photo on p.photo_id = photo.id where p.spot_id = s.id and p.is_private = false and p.deleted_at is null order by spot_id DESC, p.id DESC limit 5) as recent_post where s.id in (1, 2, 3, 7, 9); ๋๋ฏธ ๋ฐ์ดํฐ(์ฅ์ 10๊ฐ, ์ฅ์๋ณ ๋ฐฉ๋ช ๋ก 1000๊ฐ)๋ฅผ ๋ฃ๊ณ ํ ์คํธ ํด๋ณธ ๊ฒฐ๊ณผ ์ผ๋ถ์ ๋๋ค 1. post_search_idx(spot_id desc, id desc, is_private, deleted_at, photo_id) explainid | select_type | table | type | key | ref | rows | filtered | Extra1 | PRIMARY | s | index | PRIMARY | null | 10 |50 | Using where; Using index; Rematerialize ()1 | PRIMARY | | ALL | null | 5 | 100 | null2 | DEPENDENT DERIVED | p | ref | post_search_idx | photospot.s.id | 10000 | 5 | Using where; Using index2 | DEPENDENT DERIVED | photo | eq_ref | PRIMARY | photospot.p.photo_id | 1 |100 | nullexplain analyze-> Nested loop inner join (cost=1206 rows=25) (actual time=0.268..1.01 rows=25 loops=1) -> Invalidate materialized tables (row from s) (cost=1.25 rows=5) (actual time=0.0292..0.039 rows=5 loops=1) -> Filter: (s.id in (1,2,3,7,9)) (cost=1.25 rows=5) (actual time=0.0285..0.0378 rows=5 loops=1) -> Covering index scan on s using PRIMARY (cost=1.25 rows=10) (actual time=0.0269..0.033 rows=10 loops=1) -> Table scan on recent_post (cost=240..242 rows=5) (actual time=0.191..0.192 rows=5 loops=5) -> Materialize (invalidate on row from s) (cost=239..239 rows=5) (actual time=0.19..0.19 rows=5 loops=5) -> Limit: 5 row(s) (cost=239 rows=5) (actual time=0.0809..0.182 rows=5 loops=5) -> Nested loop inner join (cost=239 rows=500) (actual time=0.0806..0.181 rows=5 loops=5) -> Filter: ((p.is_private = false) and (p.deleted_at is null) and (p.photo_id is not null)) (cost=63.6 rows=500) (actual time=0.0659..0.147 rows=5 loops=5) -> Covering index lookup on p using post_search_idx (spot_id=s.id) (cost=63.6 rows=10000) (actual time=0.06..0.121 rows=140 loops=5) -> Single-row index lookup on photo using PRIMARY (id=p.photo_id) (cost=0.25 rows=1) (actual time=0.00652..0.00655 rows=1 loops=25)2. post_search_idx(spot_id desc, id desc, photo_id)explainid | select_type | table | type | key | ref | rows | filtered | Extra1 | PRIMARY | s | index | PRIMARY | null |10 |50 |Using where; Using index; Rematerialize ()1 | PRIMARY | | ALL | null | null | 5 |100 |null2 | DEPENDENT DERIVED | p | index | FKqng73nkpy18qx7h7k6wq87ygx | null | 5 |1 | Using where; Backward index scan 2 | DEPENDENT DERIVED| photo | null | eq_ref | PRIMARY | photospot.p.photo_id | 1 | 100 | nullexplain analyze-> Nested loop inner join (cost=1024 rows=0.25) (actual time=16.2..51 rows=25 loops=1) -> Invalidate materialized tables (row from s) (cost=1.25 rows=5) (actual time=0.0244..0.0368 rows=5 loops=1) -> Filter: (s.id in (1,2,3,7,9)) (cost=1.25 rows=5) (actual time=0.0241..0.0359 rows=5 loops=1) -> Covering index scan on s using PRIMARY (cost=1.25 rows=10) (actual time=0.0224..0.0289 rows=10 loops=1) -> Table scan on recent_post (cost=15.6..15.6 rows=0.05) (actual time=10.2..10.2 rows=5 loops=5) -> Materialize (invalidate on row from s) (cost=13.1..13.1 rows=0.05) (actual time=10.2..10.2 rows=5 loops=5) -> Limit: 5 row(s) (cost=13.1 rows=0.05) (actual time=10..10.2 rows=5 loops=5) -> Nested loop inner join (cost=13.1 rows=0.05) (actual time=10..10.2 rows=5 loops=5) -> Filter: ((p.is_private = false) and (p.spot_id = s.id) and (p.deleted_at is null) and (p.photo_id is not null)) (cost=0.975 rows=0.05) (actual time=10..10.2 rows=5 loops=5) -> Index scan on p using FKqng73nkpy18qx7h7k6wq87ygx (reverse) (cost=0.975 rows=5) (actual time=0.0147..9.43 rows=5727 loops=5) -> Single-row index lookup on photo using PRIMARY (id=p.photo_id) (cost=0.252 rows=1) (actual time=0.00392..0.00395 rows=1 loops=25)์กฐํ ์ฑ๋ฅ ์์ฒด๋ ์ธ๋ฑ์ค์ 2๊ฐ ์ปฌ๋ผ(is_private, deleted_at)์ ํฌํจํ๋ฉด ์ข์ ๊ฒ ๊ฐ์๋ฐ ์ ํ๋๋ ๋จ์ด์ง๊ณ where ์กฐ๊ฑด์ ๋น๊ต ์กฐ๊ฑด์ผ๋ก ์ฌ์ฉ๋๋ ์ปฌ๋ผ๋ค์ ์ธ๋ฑ์ค์ ์ถ๊ฐํ๋ฉด ์ฑ๋ฅ์ ์ธ ์ด์ ๋ณด๋ค ๋จ์ ์ด ์ปค์ง ์ ์๋ค๊ณ ํ์ ๋ถ๋ถ ๋๋ฌธ์ ๊ณ ๋ฏผ์ด ๋์ด์ ์ง๋ฌธ ๋๋ ธ์ต๋๋ค..!
- 1
- 2
- 345
Q&A
์๋น์ค์์ ์ธ๋ ํค ์ฌ์ฉ์ ๋ํด ์ง๋ฌธ ๋๋ฆฝ๋๋ค
๊ฐ์ฌํฉ๋๋ค!!
- 2
- 2
- 546
Q&A
์๋ฐฉํฅ ๋งคํ๊ด๊ณ- ์์ชฝ์ ๊ฐ์ ์ค์ ํด์ฃผ์ด์ผํ๋ค
1๋ฒ์ ๊ฐ์ ๋ท๋ถ๋ถ์ ๋ ๋ณด๊ณ ์ดํด๊ฐ ๋์์ต๋๋ค. ๊ฐ์ฌํฉ๋๋ค 2๋ฒ์ ๊ฒฝ์ฐ๋ ๋ฐ๋ก DB๋ก ์ ์ก๋๋ ์ด์ ๊ฐ ์ด๋ป๊ฒ ๋๋์?? ์์ด๋ดํฐํฐ ์ ๋ต์ด persist๋ฅผ ํ๋ฉด ๋ฐ๋ก DB์ ๋ค๋ ์ค๊ณ ์ํ์ค ์ ๋ต์ id๊ฐ์ ๋ฏธ๋ฆฌ ์์ฑ(ex 50๊ฐ)ํด์ ํ ๋นํ๋ ๊ฒ ์๋๊ฐ์?? ๊ฐ์๋ฅผ ๋ค ๋ณด๊ธด ํ๋๋ฐ ์ ๊ฐ ์์ ์๋ชป ์ดํดํ๊ณ ์์ผ๋ฉด ์ด๋ค ํ์ฐจ๋ฅผ ๋ค์ ๋ด์ผ๋ ์ง ์๋ ค์ฃผ์๋ฉด ๊ฐ์ฌํ๊ฒ ์ต๋๋ค!
- 0
- 2
- 281
Q&A
์๊ฐ๋ณต์ก๋
์ข์ ๋งํฌ ๊ฐ์ฌํฉ๋๋ค!
- 0
- 2
- 294
Q&A
์ฝ๋ ์ง๋ฌธ ๋๋ฆฝ๋๋ค.
๊ทธ ๊ฒฝ์ฐ๋ฅผ ์๊ฐ ๋ชป ํ๋ค์..! ๊ฐ์ฌํฉ๋๋ค!!
- 0
- 2
- 245
Q&A
{0} ~ {1} ์นํ ๋ฌธ์ ์ง๋ฌธ ๋๋ฆฝ๋๋ค.
๋ค ๊ฐ์ฌํฉ๋๋ค
- 0
- 2
- 357
Q&A
์นํ ๋ฌธ์(?) ์ง๋ฌธ ๋๋ฆฝ๋๋ค!
๋ต๋ณ ๊ฐ์ฌํฉ๋๋ค. ์๋ฐ format ํจ์๊ฐ ์๋ ๊ฒ์ ํ์ธํ๋๋ฐ ์ง๋ฌธ ์ข ์ ๋ฆฌํด์ ๋๋ฆฌ๊ฒ ์ต๋๋ค!1. slf4j๋ bindingResult์์ arguments๋ฅผ ์นํํ๋ ๊ฒ์ ๋ด๋ถ์ ์ผ๋ก format ํจ์๊ฐ ์ฌ์ฉ๋๋ ๊ฑด๊ฐ์?? 2. format ํจ์๋ฅผ ์ฐพ์๋ณด๋ format("%d", a)๋ ํ์ ์ง์ ์๋ฅผ ์ฌ์ฉํด์ผ ํ๋๋ฐ slf4j๋ bindingResult์ฒ๋ผ("{0}", a) ํ์ ์ง์ ์ ์์ด ์ฌ์ฉํ๋ ๊ฑด ์ด๋ป๊ฒ ๊ฐ๋ฅํ ๊ฑด๊ฐ์??
- 0
- 3
- 891
Q&A
getter ์ง๋ฌธ ๋๋ฆฝ๋๋ค!
๊ฐ์ด ๋ฐ๋๊ฒ ๋๋ ๊ฒฝ์ฐ์ ๋ํ ๊ณ ๋ ค๋ฅผ ํ์ง ๋ชป ํ๋ค์. ์ข์ ๋ต๋ณ ๊ฐ์ฌํฉ๋๋ค!!
- 0
- 2
- 244
Q&A
์ทจ์ค์ ๋ฐฉํฅ ์ข ํ๋ฒ ๋ด์ฃผ์๋ฉด ๊ฐ์ฌํ๊ฒ ์ต๋๋ค!
์คํ๋ง ๊ธฐ๋ณธํธ, ์คํ๋งMVC1,2, ์ฟผ๋ฆฌ ๊ณต๋ถ๋ฅผ ํ๊ณ JPA ๊ฐ์๋ฅผ ๋ค์ด๊ฐ๋ฉด ๋๊ฒ ๋ค์! ๋ต๋ณ ๊ฐ์ฌํฉ๋๋ค!
- 0
- 2
- 459
Q&A
RequiredArgsConstructor ์ง๋ฌธ ์์ต๋๋ค!
inteliJ๋ฅผ ์ต์ ๋ฒ์ ์ผ๋ก ์ ๋ฐ์ดํธํ๋ ์ ์์ ์ผ๋ก ์ธ์ํ๋ค์..ใ ใ ๊ฐ์ฌํฉ๋๋ค!!
- 0
- 2
- 658




