From d0fba17f8e1d342d919a4d777964050f3acf726e Mon Sep 17 00:00:00 2001 From: rlarlgnszx Date: Thu, 17 Oct 2024 17:48:09 +0900 Subject: [PATCH] =?UTF-8?q?[feat]=20Index=20=EC=B6=94=EA=B0=80=20-=20#305?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/org/dateroad/date/domain/Course.java | 8 +++++++- .../src/main/java/org/dateroad/date/domain/Date.java | 3 ++- .../src/main/java/org/dateroad/image/domain/Image.java | 4 ++-- .../src/main/java/org/dateroad/like/domain/Like.java | 3 ++- .../main/java/org/dateroad/place/domain/CoursePlace.java | 3 ++- 5 files changed, 15 insertions(+), 6 deletions(-) diff --git a/dateroad-domain/src/main/java/org/dateroad/date/domain/Course.java b/dateroad-domain/src/main/java/org/dateroad/date/domain/Course.java index fc24ddba..a37347f2 100644 --- a/dateroad-domain/src/main/java/org/dateroad/date/domain/Course.java +++ b/dateroad-domain/src/main/java/org/dateroad/date/domain/Course.java @@ -6,6 +6,7 @@ import jakarta.persistence.GeneratedValue; import jakarta.persistence.GenerationType; import jakarta.persistence.Id; +import jakarta.persistence.Index; import jakarta.persistence.Table; import jakarta.validation.constraints.NotNull; import java.time.LocalDate; @@ -25,7 +26,12 @@ @NoArgsConstructor(access = AccessLevel.PROTECTED) @AllArgsConstructor @EntityListeners(AuditingEntityListener.class) -@Table(name = "courses") +@Table(name = "courses", indexes = { + @Index(columnList = "user_id"), + @Index(name = "idx_country_city", columnList = "country, city"), + @Index(name = "idx_cost", columnList = "cost"), + @Index(name = "idx_created_at", columnList = "createdAt")} +) public class Course extends DateBase { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) diff --git a/dateroad-domain/src/main/java/org/dateroad/date/domain/Date.java b/dateroad-domain/src/main/java/org/dateroad/date/domain/Date.java index 316760ef..f35371fa 100644 --- a/dateroad-domain/src/main/java/org/dateroad/date/domain/Date.java +++ b/dateroad-domain/src/main/java/org/dateroad/date/domain/Date.java @@ -5,6 +5,7 @@ import jakarta.persistence.GeneratedValue; import jakarta.persistence.GenerationType; import jakarta.persistence.Id; +import jakarta.persistence.Index; import jakarta.persistence.Table; import java.time.LocalDate; import java.time.LocalTime; @@ -20,7 +21,7 @@ @Getter @NoArgsConstructor(access = AccessLevel.PROTECTED) @AllArgsConstructor(access = AccessLevel.PRIVATE) -@Table(name = "dates") +@Table(name = "dates",indexes = @Index(columnList = "user_id")) public class Date extends DateBase { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) diff --git a/dateroad-domain/src/main/java/org/dateroad/image/domain/Image.java b/dateroad-domain/src/main/java/org/dateroad/image/domain/Image.java index ae551f2a..e0c9dff5 100644 --- a/dateroad-domain/src/main/java/org/dateroad/image/domain/Image.java +++ b/dateroad-domain/src/main/java/org/dateroad/image/domain/Image.java @@ -6,6 +6,7 @@ import jakarta.persistence.GeneratedValue; import jakarta.persistence.GenerationType; import jakarta.persistence.Id; +import jakarta.persistence.Index; import jakarta.persistence.JoinColumn; import jakarta.persistence.ManyToOne; import jakarta.persistence.Table; @@ -15,7 +16,6 @@ import lombok.Builder; import lombok.Getter; import lombok.NoArgsConstructor; -import lombok.Setter; import org.dateroad.common.BaseTimeEntity; import org.dateroad.date.domain.Course; @@ -24,7 +24,7 @@ @AllArgsConstructor(access = AccessLevel.PRIVATE) @Builder(access = AccessLevel.PRIVATE) @Getter -@Table(name = "images") +@Table(name = "images", indexes = @Index(columnList = "course_id")) public class Image extends BaseTimeEntity { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) diff --git a/dateroad-domain/src/main/java/org/dateroad/like/domain/Like.java b/dateroad-domain/src/main/java/org/dateroad/like/domain/Like.java index e487034e..bd1f6308 100644 --- a/dateroad-domain/src/main/java/org/dateroad/like/domain/Like.java +++ b/dateroad-domain/src/main/java/org/dateroad/like/domain/Like.java @@ -6,6 +6,7 @@ import jakarta.persistence.GeneratedValue; import jakarta.persistence.GenerationType; import jakarta.persistence.Id; +import jakarta.persistence.Index; import jakarta.persistence.JoinColumn; import jakarta.persistence.ManyToOne; import jakarta.persistence.Table; @@ -22,7 +23,7 @@ @NoArgsConstructor(access = AccessLevel.PROTECTED) @AllArgsConstructor @Builder(access = AccessLevel.PRIVATE) -@Table(name = "likes") +@Table(name = "likes", indexes = @Index(columnList = "course_id")) public class Like extends BaseTimeEntity { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) diff --git a/dateroad-domain/src/main/java/org/dateroad/place/domain/CoursePlace.java b/dateroad-domain/src/main/java/org/dateroad/place/domain/CoursePlace.java index e2285e8b..6ff7d42a 100644 --- a/dateroad-domain/src/main/java/org/dateroad/place/domain/CoursePlace.java +++ b/dateroad-domain/src/main/java/org/dateroad/place/domain/CoursePlace.java @@ -2,6 +2,7 @@ import jakarta.persistence.Entity; import jakarta.persistence.FetchType; +import jakarta.persistence.Index; import jakarta.persistence.JoinColumn; import jakarta.persistence.ManyToOne; import jakarta.persistence.Table; @@ -16,7 +17,7 @@ @SuperBuilder @NoArgsConstructor(access = AccessLevel.PROTECTED) @AllArgsConstructor(access = AccessLevel.PRIVATE) -@Table(name = "course_places") +@Table(name = "course_places",indexes = @Index(columnList = "course_id")) public class CoursePlace extends Place { @ManyToOne(fetch = FetchType.LAZY) @JoinColumn(name = "course_id")