Implemented project-based late-night self-study applications. A student enters the date, time, and project details, selects team members, and submits the application.
When a student applies or a teacher changes the status (accept/reject), the application status of all participants, including the project leader, had to be updated together.
Initial Table Structure
An individual late-night self-study feature already existed. During MVP development, we reused the existing general late-night self-study table and created a separate project table that stored the project ID as a foreign key.
Problems
Unnecessary WHERE clauses were generated when querying projects. Whenever JPA looked up self-study records, it had to distinguish the self-study type by the presence of project_id, which added redundant WHERE conditions to every request.
Frequent loops and repeated SQL queries led to the JPA N+1 problem and high time complexity.
Improved Table Structure
Normalized the schema into night_study, night_study_project, and night_study_project_member tables.
Rather than relying on loops, I reduced time complexity by using IN, JOIN, and EXISTS in JPA and JPQL.
Results
Reduced response times from an average of 320ms to 87ms for POST requests and from 624ms to 49ms for PATCH requests.
Eliminated the unnecessary queries (JOINs, WHERE clauses, etc.) that had been generated when querying projects.