1031 ~ 1113


# 1031 ~ 1113

# 1031 - [Gradle] implementation vs compile

[ api(compile) ]

The dependencies required to compile the production source of the project whichย areย part of the API exposed by the project. For example the project uses Guava and exposes public interfaces with Guava classes in their method signatures.

[ implementation ]

The dependencies required to compile the production source of the project whichย are notย part of the API exposed by the project. For example the project uses Hibernate for its internal persistence layer implementation.

compile์€ ์ƒ์œ„ ๋ชจ๋“ˆ๊นŒ์ง€ ๊ฐ€์ ธ์˜จ๋‹ค. compile์€ implementation ๋ณด๋‹ค ๋” ๋งŽ์€ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ๋ฅผ ๋นŒ๋“œํ•œ๋‹ค. ์˜ˆ๋ฅผ ๋“ค์–ด ๋‹ค์Œ๊ณผ ๊ฐ™์ด ์˜์กดํ•˜๋Š” ๊ด€๊ณ„์˜ ํ”„๋กœ์ ํŠธ ์„ธ ๊ฐœ๊ฐ€ ์žˆ๋‹ค๊ณ  ๊ฐ€์ •ํ–ˆ์„ ๋•Œ

myApp -> mySpring -> myJava

compile์„ ์‚ฌ์šฉํ•ด์„œ mySpring์„ ๋นŒ๋“œํ•˜๊ฒŒ ๋˜๋ฉด ์˜์กดํ•˜๊ณ  ์žˆ๋Š” myJava๊นŒ์ง€ ํ•จ๊ป˜ ๋นŒ๋“œํ•œ๋‹ค.
implementation์„ ์‚ฌ์šฉํ•ด์„œ ๋นŒ๋“œํ•˜๋ฉด mySpring ๋ชจ๋“ˆ๋งŒ ๊ฐ€์ ธ์˜ค๊ธฐ ๋•Œ๋ฌธ์— ๋นŒ๋“œ ์†๋„๊ฐ€ ๋น ๋ฅด๊ณ  ํ•„์š”ํ•œ API๋งŒ ๋…ธ์ถœํ•ด์„œ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๋‹ค. ๋˜ํ•œ complie์€ deprecated ๋˜๊ณ  api๋กœ ๋Œ€์ฒด๋๋‹ค.


# 1103 - ์ปค์„œ ๊ธฐ๋ฐ˜ ํŽ˜์ด์ง€๋„ค์ด์…˜

[ ์˜คํ”„์…‹ ๊ธฐ๋ฐ˜ ํŽ˜์ง€ ๋„ค์…˜์˜ ํ•œ๊ณ„ ]

  • ๊ฐ๊ฐ์˜ ํŽ˜์ด์ง€๋ฅผ ์š”์ฒญํ•˜๋Š” ์‚ฌ์ด์— ๋ฐ์ดํ„ฐ์˜ ๋ณ€ํ™”๊ฐ€ ์žˆ๋Š” ๊ฒฝ์šฐ ์ค‘๋ณต ๋ฐ์ดํ„ฐ๊ฐ€ ๋…ธ์ถœ๋œ๋‹ค.
  • ๋Œ€๋ถ€๋ถ„์˜ RDBMS์—์„œ OFFSET ์ฟผ๋ฆฌ์˜ ํผํฌ๋จผ์Šค ์ด์Šˆ๊ฐ€ ์žˆ๋‹ค.

์˜คํ”„์…‹์€ ๋‹จ์ˆœํžˆ ๋ ˆ์ฝ”๋“œ๋ฅผ ์กฐํšŒํ•˜๊ธฐ ์ „์— ๋ฐ์ดํ„ฐ ๋ฒ ์ด์Šค๊ฐ€ ๊ฑด๋„ˆ ๋›ฐ๋Š” ๋ ˆ์ฝ”๋“œ์˜ ์ˆ˜๋‹ค.
์ฆ‰, ์š”์ฒญํ•œ ๋ฐ์ดํ„ฐ๋ฅผ ๋ฐ”๋กœ ์กฐํšŒํ•˜๋Š” ๊ฒƒ์ด ์•„๋‹ˆ๋ผ ์ด์ „์˜ ๋ฐ์ดํ„ฐ๋ฅผ ๋ชจ๋‘ ์กฐํšŒํ•˜๊ณ  ๊ทธ ResultSet์—์„œ ์˜คํ”„์…‹์„ ์กฐ๊ฑด์œผ๋กœ ์ž˜๋ผ๋‚ด๋Š” ๊ฒƒ์ด๋‹ค.

# ์ปค์„œ ๊ธฐ๋ฐ˜ ํŽ˜์ด์ง€๋„ค์ด์…˜(Cursor-based Pagination)์ด๋ž€?

  • ์ปค์„œ ๊ฐœ๋…์„ ์‚ฌ์šฉํ•œ๋‹ค. ์‚ฌ์šฉ์ž์—๊ฒŒ ์‘๋‹ตํ•ด์ค€ ๋งˆ์ง€๋ง‰์˜ ๋ฐ์ดํ„ฐ์˜ ์‹๋ณ„์ž ๊ฐ’์ด Cursor๊ฐ€ ๋œ๋‹ค.
  • ์ปค์„œ๋ฅผ ๊ธฐ์ค€์œผ๋กœ ๋‹ค์Œ n๊ฐœ์˜ ๋ฐ์ดํ„ฐ๋ฅผ ์‘๋‹ตํ•ด์ฃผ๋Š” ๋ฐฉ์‹์ด๋‹ค.

[ ๊ตฌํ˜„ ]

  • Querydsl
public Page<Club> findClubsByCondition(Long cursorId, ClubFindCondition condition, Account loginAccount,
                                       Pageable pageable) {

    List<AccountClub> findAccountClubs = queryFactory.selectFrom(accountClub)
						...
            .where(
                    cursorId(cursorId)
										...
            )
            .limit(pageable.getPageSize())
            .fetch();

    ...
}

private BooleanExpression cursorId(Long cursorId){
    return cursorId == null ? null : club.id.gt(cursorId);
}
public List<BookPaginationDto> paginationNoOffset(Long bookId, String name, int pageSize) {

    return queryFactory
            .select(Projections.fields(BookPaginationDto.class,
                    book.id.as("bookId"),
                    book.name,
                    book.bookNo))
            .from(book)
            .where(
                    ltBookId(bookId),
                    book.name.like(name + "%")
            )
            .orderBy(book.id.desc())
            .limit(pageSize)
            .fetch();
}

private BooleanExpression ltBookId(Long bookId) {
    if (bookId == null) {
        return null; // BooleanExpression ์ž๋ฆฌ์— null์ด ๋ฐ˜ํ™˜๋˜๋ฉด ์กฐ๊ฑด๋ฌธ์—์„œ ์ž๋™์œผ๋กœ ์ œ๊ฑฐ๋œ๋‹ค
    }

    return book.id.lt(bookId);
}

[ ๋‹จ์  ]

  • where์— ์‚ฌ์šฉ๋˜๋Š” ๊ธฐ์ค€ Key๊ฐ€ ์ค‘๋ณต์ด ๊ฐ€๋Šฅํ•  ๊ฒฝ์šฐ

    • ์ด๋ฅผ ํ…Œ๋ฉด group by ๋“ฑ์œผ๋กœ ๊ธฐ์ค€์œผ๋กœ ์žก์„ Key๊ฐ€ ์ค‘๋ณต์ด ๋  ๊ฒฝ์šฐ ์ •ํ™•ํ•œ ๊ฒฐ๊ณผ๋ฅผ ๋ฐ˜ํ™˜ํ•  ์ˆ˜ ์—†์–ด์„œ ์‚ฌ์šฉํ•  ์ˆ˜๊ฐ€ ์—†๋‹ค.
  • UX๊ด€์ ์—์„œ ํŽ˜์ด์ง• ๋ฒ„ํŠผ ํ˜•์‹์œผ๋กœ ํ•ด์•ผํ•  ๊ฒฝ์šฐ ์‚ฌ์šฉ๋ถˆ๊ฐ€


# 1109 - ์ปค๋ฒ„๋ง ์ธ๋ฑ์Šค

# Using index

์ปค๋ฒ„๋ง ์ธ๋ฑ์Šค (์ฟผ๋ฆฌ์˜ ๋ชจ๋“  ํ•ญ๋ชฉ์ด ์ธ๋ฑ์Šค ์ปฌ๋Ÿผ์œผ๋กœ ์ด๋ฃจ์–ด์ง„ ์ƒํƒœ)

# Non Clustered Key์™€ Clustered Key

  • Clustered Key
    • ๋Œ€์ƒ : PK, PK๊ฐ€ ์—†์„๋• ์œ ๋‹ˆํฌํ‚ค, ๋‘˜๋‹ค ์—†์„ ๊ฒฝ์šฐ 6byte์˜ Hidden Key๋ฅผ ์ƒ์„ฑ(rowid)
    • ์ œํ•œ : ํ…Œ์ด๋ธ”๋‹น 1๊ฐœ๋งŒ ์กด์žฌ ๊ฐ€๋Šฅ
  • Non Clustered Key
    • ๋Œ€์ƒ : ์ผ๋ฐ˜์ ์ธ ์ธ๋ฑ์Šค
    • ์ œํ•œ : ์—ฌ๋Ÿฌ๊ฐœ ์ƒ์„ฑ ๊ฐ€๋Šฅ

image

  • Non Clustered Key(์ผ๋ฐ˜์ ์ธ ์ธ๋ฑ์Šค)์—๋Š” ์ธ๋ฑ์Šค ์ปฌ๋Ÿผ์˜ ๊ฐ’๋“ค๊ณผ Clustered Key(PK)์˜ ๊ฐ’์ด ํฌํ•จ๋˜์–ด ์žˆ๋‹ค
  • Clustered Key ๋งŒ์ด ์‹ค์ œ ํ…Œ์ด๋ธ”์˜ row ์œ„์น˜๋ฅผ ์•Œ๊ณ  ์žˆ๋‹ค

์ธ๋ฑ์Šค ์กฐ๊ฑด์— ๋ถ€ํ•ฉํ•œ where ์กฐ๊ฑด์ด ์žˆ๋”๋ผ๋„ select์— ์ธ๋ฑ์Šค์— ํฌํ•จ๋œ ์ปฌ๋Ÿผ ์™ธ์— ๋‹ค๋ฅธ ์ปฌ๋Ÿผ๊ฐ’์ด ํ•„์š”ํ• ๋•Œ๋Š” Non Clustered Key์— ์žˆ๋Š” Clusterd Key ๊ฐ’์œผ๋กœ ๋ฐ์ดํ„ฐ ๋ธ”๋ก์„ ์ฐพ๋Š” ๊ณผ์ •์ด ํ•„์š”ํ•˜๋‹ค.
๋‹ค๋งŒ PK๋ฅผ ์‚ฌ์šฉํ•  ๊ฒฝ์šฐ ์ธ๋ฑ์Šค ํƒ์ƒ‰ ์‹œ๊ฐ„์ด ์—†์–ด์ง€๊ธฐ ๋•Œ๋ฌธ์— ํ–ฅ์ƒ๋œ ๋ฐ์ดํ„ฐ ํŒŒ์ผ ์ ‘๊ทผ์ด ๊ฐ€๋Šฅํ•˜๋‹ค.
์ปค๋ฒ„๋ง ์ธ๋ฑ์Šค๋Š” ์—ฌ๊ธฐ์„œ "์‹ค์ œ ๋ฐ์ดํ„ฐ ์ ‘๊ทผ"์˜ ํ–‰์œ„ ์—†์ด ์ธ๋ฑ์Šค์— ์žˆ๋Š” ์ปฌ๋Ÿผ๊ฐ’๋“ค๋กœ๋งŒ ์ฟผ๋ฆฌ๋ฅผ ์™„์„ฑํ•˜๋Š” ๊ฒƒ์„ ์ด์•ผ๊ธฐํ•œ๋‹ค.

[ WHERE + GROUP BY ] GROUP BY ์ธ๋ฑ์Šค ์ ์šฉ ์กฐ๊ฑด

  • GROUP BY ์ ˆ์— ๋ช…์‹œ๋œ ์ปฌ๋Ÿผ์ด ์ธ๋ฑ์Šค ์ปฌ๋Ÿผ์˜ ์ˆœ์„œ์™€ ๊ฐ™์•„์•ผ ํ•œ๋‹ค.
    • ์•„๋ž˜ ๋ชจ๋“  ์ผ€์ด์Šค๋Š” ์ธ๋ฑ์Šค๊ฐ€ ์ ์šฉ ์•ˆ๋œ๋‹ค. (index: a,b,c)
    • group by b
    • group by b, a
    • group by a, c, b
  • ์ธ๋ฑ์Šค ์ปฌ๋Ÿผ ์ค‘ ๋’ค์— ์ปฌ๋Ÿผ์ด GROUP BY ์ ˆ์— ๋ช…์‹œ๋˜์ง€ ์•Š์•„๋„ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๋‹ค.
    • ์•„๋ž˜ ๋ชจ๋“  ์ผ€์ด์Šค๋Š” ์ธ๋ฑ์Šค๊ฐ€ ์ ์šฉ๋œ๋‹ค. (index: a,b,c)
    • group by a
    • group by a, b
    • group by a, b, c
  • ๋ฐ˜๋Œ€๋กœ ์ธ๋ฑ์Šค ์ปฌ๋Ÿผ ์ค‘ ์•ž์— ์žˆ๋Š” ์ปฌ๋Ÿผ์ด GROUP BY ์ ˆ์— ๋ช…์‹œ๋˜์ง€ ์•Š์œผ๋ฉด ์ธ๋ฑ์Šค๋ฅผ ์‚ฌ์šฉํ•  ์ˆ˜ ์—†๋‹ค.
    • ex: (index: a,b,c), group by b, c ๋Š” ์ธ๋ฑ์Šค ์ ์šฉ ์•ˆ๋จ
  • ์ธ๋ฑ์Šค์— ์—†๋Š” ์ปฌ๋Ÿผ์ด GROUP BY ์ ˆ์— ํฌํ•จ๋˜์–ด ์žˆ์œผ๋ฉด ์ธ๋ฑ์Šค๊ฐ€ ์ ์šฉ๋˜์ง€ ์•Š๋Š”๋‹ค.
    • ex: (index: a,b,c), group by a,b,c,d ๋Š” ์ธ๋ฑ์Šค ์ ์šฉ์•ˆ๋จ

์—ฌ๊ธฐ์„œ WHERE ์กฐ๊ฑด๊ณผ GROUP BY๊ฐ€ ํ•จ๊ป˜ ์‚ฌ์šฉ๋˜๋ฉด WHERE ์กฐ๊ฑด์ด ๋™๋“ฑ ๋น„๊ต์ผ ๊ฒฝ์šฐ GROUP BY ์ ˆ์— ํ•ด๋‹น ์ปฌ๋Ÿผ์€ ์—†์–ด๋„ ์ธ๋ฑ์Šค๊ฐ€ ์ ์šฉ๋œ๋‹ค.

WHERE a = 1 
GROUP BY b, c

WHERE a = 1 and b = 'b'
GROUP BY c

# 1113 - ์ปค๋ฒ„๋ง ์ธ๋ฑ์Šค๋ฅผ ํ™œ์šฉํ•œ ํŽ˜์ด์ง• ์„ฑ๋Šฅ ๊ฐœ์„ 

์ปค๋ฒ„๋ง ์ธ๋ฑ์Šค๋ž€ ์ฟผ๋ฆฌ๋ฅผ ์ถฉ์กฑ์‹œํ‚ค๋Š” ๋ฐ ํ•„์š”ํ•œ ๋ชจ๋“  ๋ฐ์ดํ„ฐ๋ฅผ ๊ฐ–๊ณ  ์žˆ๋Š” ์ธ๋ฑ์Šค๋ฅผ ์ด์•ผ๊ธฐํ•œ๋‹ค.
์ฆ‰, select, where, order by, limit, group by ๋“ฑ์—์„œ ์‚ฌ์šฉ๋˜๋Š” ๋ชจ๋“  ์ปฌ๋Ÿผ์ด Index ์ปฌ๋Ÿผ์•ˆ์— ๋‹ค ํฌํ•จ๋œ ๊ฒฝ์šฐ์ด๋‹ค.

ํŽ˜์ด์ง• ์„ฑ๋Šฅ์„ ๊ฐœ์„ ํ• ๋•Œ๋‚˜ ์‹ค์ œ๋กœ ์ปค๋ฒ„๋ง ์ธ๋ฑ์Šค๋ฅผ ํƒœ์šฐ๋Š” ๋ถ€๋ถ„์€ select๋ฅผ ์ œ์™ธํ•œ ๋‚˜๋จธ์ง€๋งŒ ์šฐ์„ ์œผ๋กœ ์ˆ˜ํ–‰ํ•œ๋‹ค.

-- AS BE
SELECT *
FROM items
WHERE ์กฐ๊ฑด๋ฌธ
ORDER BY id DESC
OFFSET ํŽ˜์ด์ง€๋ฒˆํ˜ธ
LIMIT ํŽ˜์ด์ง€์‚ฌ์ด์ฆˆ

-- TO BE
SELECT  *
FROM  items as i
JOIN (SELECT id
        FROM items
        WHERE ์กฐ๊ฑด๋ฌธ
        ORDER BY id DESC
        OFFSET ํŽ˜์ด์ง€๋ฒˆํ˜ธ
        LIMIT ํŽ˜์ด์ง€์‚ฌ์ด์ฆˆ) as temp on temp.id = i.id

[ ์ปค๋ฒ„๋ง ์ธ๋ฑ์Šค๊ฐ€ ๋น ๋ฅธ์ด์œ  ]
์ผ๋ฐ˜์ ์œผ๋กœ ์ธ๋ฑ์Šค๋ฅผ ์ด์šฉํ•ด ์กฐํšŒ๋˜๋Š” ์ฟผ๋ฆฌ์—์„œ ๊ฐ€์žฅ ํฐ ์„ฑ๋Šฅ ์ €ํ•˜๋ฅผ ์ผ์œผํ‚ค๋Š” ๋ถ€๋ถ„์€ ์ธ๋ฑ์Šค๋ฅผ ๊ฒ€์ƒ‰ํ•˜๊ณ  ๋Œ€์ƒ์ด ๋˜๋Š” row์˜ ๋‚˜๋จธ์ง€ ์ปฌ๋Ÿผ๊ฐ’์„ ๋ฐ์ดํ„ฐ ๋ธ”๋ก์—์„œ ์ฝ์„ ๋•Œ์ด๋‹ค.
ํŽ˜์ด์ง• ์ฟผ๋ฆฌ์™€ ๋ฌด๊ด€ํ•˜๊ฒŒ ์ธ๋ฑ์Šค๋ฅผ ํƒ”์Œ์—๋„ ๋Š๋ฆฐ ์ฟผ๋ฆฌ์˜ ๊ฒฝ์šฐ ์ด select์ ˆ ํ•ญ๋ชฉ๋•Œ๋ฌธ์ด๋‹ค.
์ด๋ฅผํ…Œ๋ฉด ์ปค๋ฒ„๋ง ์ธ๋ฑ์Šค๋ฅผ ํƒœ์šฐ์ง€ ์•Š์€ ์ผ๋ฐ˜์ ์ธ ์กฐํšŒ ์ฟผ๋ฆฌ๋Š” order by, offset ~ limit์„ ์ˆ˜ํ–‰ํ• ๋•Œ๋„ ๋ฐ์ดํ„ฐ ๋ธ”๋ก์œผ๋กœ ์ ‘๊ทผํ•˜๊ฒŒ ๋œ๋‹ค. image ๋ฐ˜๋Œ€๋กœ ์ปค๋ฒ„๋ง ์ธ๋ฑ์Šค ๋ฐฉ์‹์„ ์ด์šฉํ•˜๋ฉด, where, order by, offset ~ limit์„ ์ธ๋ฑ์Šค ๊ฒ€์ƒ‰์œผ๋กœ ๋น ๋ฅด๊ฒŒ ์ฒ˜๋ฆฌํ•˜๊ณ , ์ด๋ฏธ ๋‹ค ๊ฑธ๋Ÿฌ์ง„ 10๊ฐœ์˜ row์— ๋Œ€ํ•ด์„œ๋งŒ ๋ฐ์ดํ„ฐ ๋ธ”๋ก์— ์ ‘๊ทผํ•˜๊ธฐ ๋•Œ๋ฌธ์— ์„ฑ๋Šฅ์˜ ์ด์ ์„ ์–ป๊ฒŒ ๋œ๋‹ค. image

[ Querydsl-JPA ๊ตฌํ˜„์ฝ”๋“œ ]
querydsl-jpa์—์„œ ์ปค๋ฒ„๋ง ์ธ๋ฑ์Šค๋ฅผ ์‚ฌ์šฉํ•ด์•ผ ํ•œ๋‹ค๋ฉด 2๊ฐœ์˜ ์ฟผ๋ฆฌ๋กœ ๋ถ„๋ฆฌํ•ด์„œ ์ง„ํ–‰ํ•  ์ˆ˜ ๋ฐ–์— ์—†๋‹ค. ์ด์œ ๋Š” Querydsl-jpa์—์„œ from์ ˆ์˜ ์„œ๋ธŒ์ฟผ๋ฆฌ๋ฅผ ์ง€์›ํ•˜์ง€ ์•Š๊ธฐ ๋•Œ๋ฌธ์ด๋‹ค.

  • ์ปค๋ฒ„๋ง ์ธ๋ฑ์Šค๋ฅผ ํ™œ์šฉํ•ด ์กฐํšŒ ๋Œ€์ƒ์˜ PK๋ฅผ ์กฐํšŒ
  • ํ•ด๋‹น PK๋กœ ํ•„์š”ํ•œ ์ปฌ๋Ÿผํ•ญ๋ชฉ๋“ค ์กฐํšŒ
public List<BookPaginationDto> paginationCoveringIndex(String name, int pageNo, int pageSize) {
        // 1) ์ปค๋ฒ„๋ง ์ธ๋ฑ์Šค๋กœ ๋Œ€์ƒ ์กฐํšŒ
        List<Long> ids = queryFactory
                .select(book.id)
                .from(book)
                .where(book.name.like(name + "%"))
                .orderBy(book.id.desc())
                .limit(pageSize)
                .offset(pageNo * pageSize)
                .fetch();

        // 1-1) ๋Œ€์ƒ์ด ์—†์„ ๊ฒฝ์šฐ ์ถ”๊ฐ€ ์ฟผ๋ฆฌ ์ˆ˜ํ–‰ ํ•  ํ•„์š” ์—†์ด ๋ฐ”๋กœ ๋ฐ˜ํ™˜
        if (CollectionUtils.isEmpty(ids)) {
            return new ArrayList<>();
        }

        // 2)
        return queryFactory
                .select(Projections.fields(BookPaginationDto.class,
                        book.id.as("bookId"),
                        book.name,
                        book.bookNo,
                        book.bookType))
                .from(book)
                .where(book.id.in(ids))
                .orderBy(book.id.desc())
                .fetch(); // where in id๋งŒ ์žˆ์–ด ๊ฒฐ๊ณผ ์ •๋ ฌ์ด ๋ณด์žฅ๋˜์ง€ ์•Š๋Š”๋‹ค.
}

[ JdbcTemplate ๊ตฌํ˜„์ฝ”๋“œ ]

public List<BookPaginationDto> paginationCoveringIndexSql(String name, int pageNo, int pageSize) {
String query =
        "SELECT i.id, book_no, book_type, name " +
        "FROM book as i " +
        "JOIN (SELECT id " +
        "       FROM book " +
        "       WHERE name LIKE '?%' " +
        "       ORDER BY id DESC " +
        "       LIMIT ? " +
        "       OFFSET ?) as temp on temp.id = i.id";

return jdbcTemplate
        .query(query, new BeanPropertyRowMapper<>(BookPaginationDto.class),
                name,
                pageSize,
                pageNo * pageSize);
}

[ ๋‹จ์  ]

  • ๋„ˆ๋ฌด ๋งŽ์€ ์ธ๋ฑ์Šค๊ฐ€ ํ•„์š”ํ•˜๋‹ค
    • ๊ฒฐ๊ตญ ์ฟผ๋ฆฌ์˜ ๋ชจ๋“  ํ•ญ๋ชฉ์ด ์ธ๋ฑ์Šค์— ํฌํ•จ๋˜์–ด์•ผํ•˜๊ธฐ ๋•Œ๋ฌธ์— ๋Š๋ฆฐ ์ฟผ๋ฆฌ๊ฐ€ ๋ฐœ์ƒํ• ๋•Œ๋งˆ๋‹ค ์ธ๋ฑ์Šค๊ฐ€ ์‹ ๊ทœ ์ƒ์„ฑ๋  ์ˆ˜๋„ ์žˆ๋‹ค.
  • ์ธ๋ฑ์Šค ํฌ๊ธฐ๊ฐ€ ๋„ˆ๋ฌด ์ปค์ง„๋‹ค
    • ์ธ๋ฑ์Šค๋„ ๊ฒฐ๊ตญ ๋ฐ์ดํ„ฐ์ด๊ธฐ ๋•Œ๋ฌธ์— ๋„ˆ๋ฌด ๋งŽ์€ ํ•ญ๋ชฉ์ด ๋“ค์–ด๊ฐ€๋ฉด ์„ฑ๋Šฅ ์ƒ ์ด์Šˆ๊ฐ€ ๋ฐœ์ƒํ•  ์ˆ˜ ๋ฐ–์— ์—†๋Š”๋ฐ, where์ ˆ์— ํ•„์š”ํ•œ ์ปฌ๋Ÿผ์™ธ์—๋„ order by, group by, having ๋“ฑ์— ๋“ค์–ด๊ฐ€๋Š” ์ปฌ๋Ÿผ๋“ค๊นŒ์ง€ ์ธ๋ฑ์Šค์— ๋“ค์–ด๊ฐ€๊ฒŒ ๋˜๋ฉด ์ธ๋ฑ์Šค ํฌ๊ธฐ๊ฐ€ ๋„ˆ๋ฌด ๋น„๋Œ€ํ•ด์ง„๋‹ค.
  • ๋ฐ์ดํ„ฐ ์–‘์ด ๋งŽ์•„์ง€๊ณ , ํŽ˜์ด์ง€ ๋ฒˆํ˜ธ๊ฐ€ ๋’ค๋กœ ๊ฐˆ์ˆ˜๋ก NoOffset์— ๋น„ํ•ด ๋Š๋ฆฌ๋‹ค.
    • ์‹œ์ž‘ ์ง€์ ์„ PK๋กœ ์ง€์ •ํ•˜๊ณ  ์กฐํšŒํ•˜๋Š” NoOffset ๋ฐฉ์‹์— ๋น„ํ•ด์„œ ์„ฑ๋Šฅ ์ฐจ์ด๊ฐ€ ์žˆ์Œ (NoOffset๊ณผ ๋™์ผํ•œ ๋ฐ์ดํ„ฐ ์กฐํšŒ์‹œ ์ปค๋ฒ„๋ง ์ธ๋ฑ์Šค ๋ฐฉ์‹์€ 272ms, No Offset์€ 83ms)
    • ํ…Œ์ด๋ธ” ์‚ฌ์ด์ฆˆ๊ฐ€ ๊ณ„์† ์ปค์ง€๋ฉด No Offset ๋ฐฉ์‹์— ๋น„ํ•ด์„œ๋Š” ์„ฑ๋Šฅ ์ฐจ์ด๊ฐ€ ๋ฐœ์ƒ
Last update: November 15, 2022 23:32
Contributors: jaesungahn91