From aa3267c5a881489bbd31f5bcb3c882255d6a7d71 Mon Sep 17 00:00:00 2001 From: pricelees Date: Sat, 11 Oct 2025 12:07:04 +0900 Subject: [PATCH] =?UTF-8?q?refactor:=20=EB=B0=B0=ED=8F=AC=20=ED=99=98?= =?UTF-8?q?=EA=B2=BD=EC=97=90=EC=84=9C=20slow-query=EC=9D=98=20=EC=9B=90?= =?UTF-8?q?=EC=9D=B8=EC=9D=B4=20=EB=90=9C=20NOT=20EXIST=20->=20LEFT=20JOIN?= =?UTF-8?q?=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../infrastructure/persistence/ScheduleRepository.kt | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/service/src/main/kotlin/com/sangdol/roomescape/schedule/infrastructure/persistence/ScheduleRepository.kt b/service/src/main/kotlin/com/sangdol/roomescape/schedule/infrastructure/persistence/ScheduleRepository.kt index 4f8f4275..15850467 100644 --- a/service/src/main/kotlin/com/sangdol/roomescape/schedule/infrastructure/persistence/ScheduleRepository.kt +++ b/service/src/main/kotlin/com/sangdol/roomescape/schedule/infrastructure/persistence/ScheduleRepository.kt @@ -134,14 +134,14 @@ interface ScheduleRepository : JpaRepository { s.id FROM schedule s + LEFT JOIN + reservation r + ON + r.schedule_id = s.id AND r.status IN ('PENDING', 'PAYMENT_IN_PROGRESS') WHERE s.status = 'HOLD' AND s.hold_expired_at <= :now - AND NOT EXISTS ( - SELECT 1 - FROM reservation r - WHERE r.schedule_id = s.id AND (r.status = 'PENDING' OR r.status = 'PAYMENT_IN_PROGRESS') - ) + AND r.id IS NULL FOR UPDATE SKIP LOCKED """, nativeQuery = true )