Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions INDEX.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ ON movie (age_rating, movie_id, genre);

인덱스 사용 전 후 비교

![image.png](attachment:f2fe2ebd-d508-4d26-ad10-6028d71b67b6:image.png)
<img width="951" height="79" alt="스크린샷 2025-11-15 오전 2 42 53" src="https://github.com/user-attachments/assets/fec669c8-50e8-4622-9a90-479d907e786a" />

실행 전에는 Durationn이 0.00079sec, fetch가 0.000016 sec이었다.

Expand All @@ -75,7 +75,7 @@ ON movie (age_rating, movie_id, genre);

그렇다면 인덱스는 데이터가 수천~수만 건일 때 효율적이라는 걸 확인

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

데이터 양이 적은 경우에는 오히려 인덱스가 비효율적이기도 하군요..! 여기 내용 중에 언급하신 인덱스 관리 비용에 포함되는 것들은 무엇인지 같이 알아보면 좋을 것 같습니다.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

제가 전에 조사했을 때는 데이터 양이 적은 경우, 또는 엔티티 구조가 복잡하지 않은 경우에는 불필요하다고 나와있었습니다! 다른 건 같이 알아보면 좋을 거 같아요~~
트랜잭션 부분도 다시 올렸으니 시간되실 때 확인 부탁드립니다!


![image.png](attachment:be16d42e-4a69-48aa-8e92-e66f7cfda108:image.png)
<img width="1115" height="602" alt="스크린샷 2025-11-15 오전 2 39 56" src="https://github.com/user-attachments/assets/ef92d258-759d-474c-8f39-85dc2b87c30e" />

실제로 데이터를 1200건 넣었고, 데이터가 많을 때는 인덱스가 효과적이라는 사실을 알 수 있었다

Expand All @@ -85,11 +85,11 @@ ON movie (age_rating, movie_id, genre);
select movie_id, genre from movie where age_rating = 'ALL' GROUP BY movie_id, genre;
```

![image.png](attachment:df54f3b9-8185-425c-ad84-4e21b488e8aa:image.png)
<img width="802" height="242" alt="image" src="https://github.com/user-attachments/assets/a800c507-2fb9-4da5-b36f-53f48a00bb5c" />

explain으로 확인한 결과 커버링 인덱스 사용하는 거 확인

![image.png](attachment:96ebb339-c0da-4e71-bde9-c85f322879cf:image.png)
<img width="642" height="58" alt="image" src="https://github.com/user-attachments/assets/19f88adc-6fae-4dd5-8807-b48991061eed" />

duration이 0.0010 → 0.00089, fetch가 0.000015 → 0.000014로 줄어든 걸 확인할 수 있었다.

Expand Down Expand Up @@ -119,6 +119,10 @@ CREATE INDEX idx_schedule_movie_theater_start
ON schedule (movie_id, theater_id, start_time);
```

![image.png](attachment:f9bb6e9a-7421-4716-a6c5-d5ce0ede626a:image.png)
<img width="998" height="99" alt="image" src="https://github.com/user-attachments/assets/f35fb97b-3cbf-476d-bc3d-121e5ead547e" />


<img width="1023" height="72" alt="image" src="https://github.com/user-attachments/assets/b8d7ac6f-7bed-4215-9a55-860258446fee" />

duration은 0.0020 → 0.0012, fetch는 0.000016 → 0.000012로 줄어든 걸 확인할 수 있다!

duration은 0.0020 → 0.0012, fetch는 0.000016 → 0.000012로 줄어든 걸 확인할 수 있다
2 changes: 1 addition & 1 deletion TRANSACTION.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
- NEVER
- NESTED

![image.png](attachment:c2f0b822-2c0e-4b20-857a-1324e67944ff:image.png)
<img width="1141" height="593" alt="image" src="https://github.com/user-attachments/assets/3513a857-73bc-4d2d-b099-c49596ccd2c9" />

개인적으로 둘의 차이를 정리해보고 싶어 표로 정리했다.

Expand Down