inflearn logo
강의

강의

N
챌린지

챌린지

멘토링

멘토링

N
클립

클립

로드맵

로드맵

지식공유

묻고 답해요

172만명의 커뮤니티!! 함께 토론해봐요.

스프링 부트3와 카운트 쿼리 분리

해결됨

실전! 스프링 데이터 JPA

학습하는 분들께 도움이 되고, 더 좋은 답변을 드릴 수 있도록 질문전에 다음을 꼭 확인해주세요. 1. 강의 내용과 관련된 질문을 남겨주세요. 2. 인프런의 질문 게시판과 자주 하는 질문(링크)을 먼저 확인해주세요. (자주 하는 질문 링크: https://bit.ly/3fX6ygx) 3. 질문 잘하기 메뉴얼(링크)을 먼저 읽어주세요. (질문 잘하기 메뉴얼 링크: https://bit.ly/2UfeqCG) 질문 시에는 위 내용은 삭제하고 다음 내용을 남겨주세요. ========================================= [질문 템플릿] 1. 강의 내용과 관련된 질문인가요? (예/아니오) 2. 인프런의 질문 게시판과 자주 하는 질문에 없는 내용인가요? (예/아니오) 3. 질문 잘하기 메뉴얼을 읽어보셨나요? (예/아니오) [질문 내용] 안녕하세요. 카운트 쿼리 분리 부분을 듣는 도중에 카운트 쿼리에 LEFT JOIN이 사용되는 결과를 확인하기 위해 다음처럼 코드를 작성하였습니다. public interface MemberRepository extends JpaRepository<Member, Long> { @Query(value = "select m from Member m left join m.team t") Page<Member> findByAge(int age, Pageable pageable); ... } @Test public void paging() throws Exception { //given memberRepository.save(new Member("member1", 10)); memberRepository.save(new Member("member2", 10)); memberRepository.save(new Member("member3", 10)); memberRepository.save(new Member("member4", 10)); memberRepository.save(new Member("member5", 10)); //when PageRequest pageRequest = PageRequest.of(0, 3, Sort.by(Sort.Direction.ASC, "username")); Page<Member> page = memberRepository.findByAge(10, pageRequest); //then List<Member> content = page.getContent(); assertThat(content.size()).isEqualTo(3); assertThat(page.getTotalElements()).isEqualTo(5); assertThat(page.getNumber()).isEqualTo(0); assertThat(page.getTotalPages()).isEqualTo(2); assertThat(page.isFirst()).isTrue(); assertThat(page.hasNext()).isTrue(); } 그런데 결과는 강의와는 달리 카운트 쿼리에 LEFT JOIN 이 사용되지 않았고, 심지어 JPQL select m from Member m left join m.team t 을 @Query에 작성했음에도 조회 쿼리도 LEFT JOIN을 사용하지 않은 것을 확인했습니다. 이후 스프링 부트 3 이하 버전에서 동일한 코드로 실행해보니 강의와 동일한 결과를 얻을 수 있었습니다. 스프링 부트 3 부터 적용된 스프링 데이터 JPA 에서는 이러한 부분의 최적화를 자동으로 제공하는 것일까요?

  • java
  • spring
  • spring-boot
  • jpa
조약돌 댓글 1 좋아요 1 조회수 774

자바 공부법

미해결

즐거운 자바

안녕하세요. 백엔드 개발자 희망하고 있습니다. 자바 독학 공부 시작했는데 기본문법 예제들은 혼자 짤 수 있는데 객체지향/3 로또 부분부터 어렵네요. 구구단, 별찍기 하다가 로또 구현할 수 있을때까지 공부 방법이 궁금합니다. ㅠ.ㅠ 자바 공부 방법 알려주세요 ㅠㅠㅠ 지금은 강사님 강의 보고 이해가 부족하다는 부분 이론서 보면서 나가고있습니다. 이론서에 나와있는 문제들도 타이핑 하면서 진행하구 있습니다. 길게 코드 작성할 수 있을때까지 자바 공부 방법 알려주세요.

  • java
  • 자바공부
댓글 2 좋아요 1 조회수 1727

싸이월드 실습 4탄 질문이요 ㅠㅠ

미해결

[코드캠프] 부트캠프에서 만든 고농축 프론트엔드 코스

싸이월드 실습 4탄 하는 중인데 LOTTO 부분에 "특히 버튼과 숫자박스 부분"이 왜 세로로 다닥다닥 붙어있을까요..ㅠ game__container 부분에 flex-direction: column; align-items: center; justify-content: space-between; padding: 20px; 가 들어있고 lotto__text부분에도 display: flex; flex-direction: column; align-items: center; justify-content: space-between; 를 넣어봤으나 아무 변화가 없었습니다 ㅠ game.html: <!DOCTYPE html> <html lang="ko"> <head> <title>Game</title> <link href="./styles/game.css" rel="stylesheet"> </head> <body> <div class="wrapper"> <div class="wrapper__header"> <div class="header__title"> <div class="title">GAME</div> <div class="subtitle">TODAY CHOICE</div> </div> <div class="divideLine"></div> </div> <div class="game__container"> <img src="./images/word.png"> <div class="game__title">끝말잇기</div> <div class="game__subtitle">제시어 : <span id="word">코드캠프</span> </div> <div class="word__text"> <input class="textbox" id="myword" placeholder="단어를 입력하세요"> <button class="search">입력</button> </div> <div class="word__result" id="result">결과!</div> </div> <div class="game__container"> <img src="./images/lotto.png"> <div class="game__title">LOTTO</div> <div class="game__subtitle"> 버튼을 누르세요. </div> <div class="lotto__text"> <div class="number__box"> <div class="number1">3</div> <div class="number1">5</div> <div class="number1">10</div> <div class="number1">24</div> <div class="number1">30</div> <div class="number1">34</div> </div> <button class="lotto_button">Button</button> </div> </div> </div> </body> </html> game.css: * { box-sizing: border-box; margin: 0px } html, body{ width: 100%; height: 100%; } .wrapper { width: 100%; height: 100%; padding: 20px; display: flex; flex-direction: column; /* 박스가 wrapper안에 game__container 두개 총 세개*/ align-items: center; justify-content: space-between; } .wrapper__header{ width: 100%; display: flex; flex-direction: column; } .header__title{ display: flex; flex-direction: row; align-items: center; } .title{ color: #55b2e4; font-size: 13px; font-weight: 700; } .subtitle{ font-size: 8px; padding-left: 5px; } .divideLine{ width: 100%; border-top: 1px solid gray; } .game__container{ width: 222px; height: 168px; border: 1px solid gray; border-radius: 15px; display: flex; flex-direction: column; align-items: center; justify-content: space-between; padding: 20px; background-color: #f6f6f6; } .game__title { font-size: 15px; font-weight: 900; } .game__subtitle { font-size: 11px; } .word__result { font-size: 11px; font-weight: 700; } .word__text { width: 100%; display: flex; flex-direction: row; justify-content: space-between; } .textbox { width: 130px; height: 24px; border-radius: 5px; } .search { font-size: 11px; font-weight: 700; width: 38px; height: 24px; } .number__box{ width: 130px; height: 24px; border-radius: 5px; background-color: #FFE400 ; display: flex; flex-direction: row; justify-content: space-between; align-items: center; } .lotto__text { display: flex; flex-direction: column; align-items: center; justify-content: space-between; } .number1{ font-size: 10px; font-weight: 700px; margin: 5px; } .lotto_button { font-size: 11px; font-weight: 700; width: 62px; height: 24px; }

  • react
  • node.js
  • seo
  • graphql
  • next.js
전현욱 댓글 2 좋아요 0 조회수 471

강의내용

미해결

갖고노는 MySQL 데이터베이스 by 얄코

강의에서 나온 내용들 혹시 수시로 참고하기 위해 개인 블로그에 따로 작성해도 괜찮을까요 ?

  • sql
  • mysql
  • dbms/rdbms
  • 데이터-엔지니어링
조재국 댓글 1 좋아요 0 조회수 618

async await

미해결

따라하며 배우는 리액트 A-Z[19버전 반영]

안녕하세요. banner.js에서 질문이 있습니다 이 부분에서 왜 async await를 사용하셨는지 궁금합니다! const fetchData = async () => { // 현재 상영중인 영화 정보를 가져오기(여러 영화) const request = await axios.get(requests.fetchNowPlaying); // 여러 영화 중 영화 하나의 ID를 가져오기 const movieId = request.data.results[ Math.floor(Math.random() * request.data.results.length) ].id; // 특정 영화의 더 상세한 정보를 가져오기(비디오 정보도 포함) const { data : movieDetail } = await axios.get(`movie/${movieId}`, { params: {append_to_response: "videos"}, }); setMovie(movieDetail); }

  • react
  • redux
  • tdd
  • typescript
  • next.js
  • 소프트웨어-테스트
puding0712 댓글 1 좋아요 0 조회수 372

spring 2.x - Querydsl 이슈있는분들 참고하세요

미해결

실전! 스프링 부트와 JPA 활용2 - API 개발과 성능 최적화

학습하는 분들께 도움이 되고, 더 좋은 답변을 드릴 수 있도록 질문전에 다음을 꼭 확인해주세요. 1. 강의 내용과 관련된 질문을 남겨주세요. 2. 인프런의 질문 게시판과 자주 하는 질문(링크)을 먼저 확인해주세요. (자주 하는 질문 링크: https://bit.ly/3fX6ygx) 3. 질문 잘하기 메뉴얼(링크)을 먼저 읽어주세요. (질문 잘하기 메뉴얼 링크: https://bit.ly/2UfeqCG) 질문 시에는 위 내용은 삭제하고 다음 내용을 남겨주세요. ========================================= [질문 템플릿] 1. 강의 내용과 관련된 질문인가요? (예/아니오) 2. 인프런의 질문 게시판과 자주 하는 질문에 없는 내용인가요? (예/아니오) 3. 질문 잘하기 메뉴얼을 읽어보셨나요? (예/아니오) [질문 내용] plugins { id 'org.springframework.boot' version '2.6.5' id 'io.spring.dependency-management' version '1.0.11.RELEASE' id 'java' id "com.ewerk.gradle.plugins.querydsl" version "1.0.10" } group = 'com.example' version = '0.0.1-SNAPSHOT' sourceCompatibility = '11' ext["hibernate.version"] = " 5.6.5.Final " configurations { compileOnly { extendsFrom annotationProcessor } } repositories { mavenCentral() } dependencies { implementation 'org.springframework.boot:spring-boot-starter-thymeleaf' implementation 'org.springframework.boot:spring-boot-starter-web' implementation 'javax.validation:validation-api' implementation 'com.fasterxml.jackson.datatype:jackson-datatype-hibernate5' //JdbcTemplate 추가 //implementation 'org.springframework.boot:spring-boot-starter-jdbc' //MyBatis 추가 implementation 'org.mybatis.spring.boot:mybatis-spring-boot-starter:2.2.0' //JPA, 스프링 데이터 JPA 추가 implementation 'org.springframework.boot:spring-boot-starter-data-jpa' //Querydsl 추가 implementation 'com.querydsl:querydsl-jpa' annotationProcessor "com.querydsl:querydsl-apt:$ { dependencyManagement.importedProperties['querydsl.version'] } :jpa" annotationProcessor "jakarta.annotation:jakarta.annotation-api" annotationProcessor "jakarta.persistence:jakarta.persistence-api" //H2 데이터베이스 추가 runtimeOnly 'com.h2database:h2' compileOnly 'org.projectlombok:lombok' annotationProcessor 'org.projectlombok:lombok' testImplementation 'org.springframework.boot:spring-boot-starter-test' //테스트에서 lombok 사용 testCompileOnly 'org.projectlombok:lombok' testAnnotationProcessor 'org.projectlombok:lombok' } tasks.named('test') { useJUnitPlatform() } //querydsl 추가 //def querydslDir = '$buildDir/generated' def querydslDir = "src/main/generated" //clean { // delete file(generated) //} querydsl { library = "com.querydsl:querydsl-apt" jpa = true querydslSourcesDir = querydslDir } sourceSets { main { java { srcDirs = ['src/main/java', querydslDir] } } } compileQuerydsl { options.annotationProcessorPath = configurations.querydsl } configurations { querydsl.extendsFrom compileClasspath } 강사님이 올려주신 내용 + 구글링 + 직접 수정했습니다. 간혹, 빌드는 되는데 generated 파일에 QClass 안보이시는 분들은 queryDsl 저장되는 경로에 $buildDir 대신 'src/main/'으로 해보세요

  • java
  • spring
  • spring-boot
  • jpa
henn36 댓글 1 좋아요 4 조회수 1264

강사님 조건에 하나일때와 두개 일때가 차이가 있더라구요

해결됨

데이터 분석 SQL Fundamentals

제가 작성한 SQL select * from nw.orders o where o.order_id in ( select max(order_id) from nw.orders a group by a.customer_id ); 강사님이 작성한 SQL select * from nw.orders where (customer_id, order_date) in (select customer_id, max(order_date) from nw.orders group by customer_id); 강사님 서브쿼리 강의 추가해주셔서 감사합니다. 제 기억에는 강사님께서 IN 연산자로 사용할 경우 세미 조인처럼 연결된다고 하셨던거 같은데 실행을 해보니까 조건이 하나 일때에는 세미 조인이지만 조건이 2개가 되니까 해쉬 조인으로 바뀌더라구요 그 이유가 궁금합니다.

  • sql
  • postgresql
  • dbms/rdbms
cjh 댓글 1 좋아요 0 조회수 273

강의 연장이 가능할런지요?

해결됨

SW 개발자를 위한 성능 좋은 SQL 쿼리 작성법

안녕하세요. 개인 사정으로 강좌를 듣지 못하다가, 다시 들으려니, 도저히 기한네 (6/29) 마칠 자신이 없어 부득불 1달 정 도 연장을 부탁드렸으면 합니다. "SW 개발자를 위한 성능 좋은 SQL 쿼리 작성법" "SQL Server 컨설턴트가 알려주는, 쿼리 능력 레벨업(고급 T-SQL 쿼리)" 번거롭게 해드려서 죄송하다는 말씀과 함께, 부탁을 드립니다. 감사합니다.

  • sql
  • dbms/rdbms
y2lee77 댓글 1 좋아요 0 조회수 425

강사님 group by에서 궁금한게 있습니다.

해결됨

데이터 분석 SQL Fundamentals

with temp_01 as ( select b.category_id, b.category_name as category_name , percentile_disc(0.25) within group (order by unit_price) as qt_1 , percentile_disc(0.5) within group (order by unit_price) as qt_2 , percentile_disc(0.75) within group (order by unit_price) as qt_3 , percentile_disc(1.0) within group (order by unit_price) as qt_4 from nw.products a join nw.categories b on a.category_id = b.category_id group by b.category_id ) select * from temp_01; 2번 with temp_01 as ( select a.category_id, max(b.category_name) as category_name , percentile_disc(0.25) within group (order by unit_price) as qt_1 , percentile_disc(0.5) within group (order by unit_price) as qt_2 , percentile_disc(0.75) within group (order by unit_price) as qt_3 , percentile_disc(1.0) within group (order by unit_price) as qt_4 from nw.products a join nw.categories b on a.category_id = b.category_id group by a.category_id ) select * from temp_01; 2번은 강사님이 작성하신 코드입니다. 1번처럼 작성하지 않으시고 2번으로 작성하신 이유가 따로 있으신가요 ? 인덱스가 중복되는게 있으면 효율이 안좋아서 fk인 a.category를 사용하는게 더 좋아서 선택하신건지 아니면 1번이나 2번이나 둘다 큰 의미가 없는건지 궁금합니다.

  • sql
  • postgresql
  • dbms/rdbms
cjh 댓글 1 좋아요 0 조회수 293

category=soup.select()

미해결

[리뉴얼] 처음하는 SQL과 데이터베이스(MySQL) 부트캠프 [입문부터 활용까지]

[참고] 크롤링과 데이터베이스 - 스키마 구현/크롤링 시작 (업데이트) 11:52 category=soup.select()에서 category가 원래는 리스트로 나오는 것으로 이해하고 있었는데 리스트가 아니라 딕셔너리형태로 나오는 이유가 궁금합니다

  • python
  • sql
  • mysql
  • dbms/rdbms
  • 데이터-엔지니어링
이하윤 댓글 1 좋아요 0 조회수 346

수업 장표 다운로드

미해결

데이터 분석 SQL Fundamentals

안녕하세요. 강의 영상에 나오는 학습 자료(ppt 장표)는 어디에서 다운받을 수 있을까요? 감사합니다!

  • sql
  • postgresql
  • dbms/rdbms
황이주 댓글 1 좋아요 0 조회수 328

JPA 특징 중 자동 업데이트 관련

미해결

실전! 스프링 부트와 JPA 활용1 - 웹 애플리케이션 개발

주문 서비스 개발 부분 강의를 듣다가 궁금한 점이 있어 질문드립니다. 주문 취소(OrderService.cancelOrder) 부분에서order.cancel() 만 작성하면 JPA 특징으로 인해, 데이터 업데이트 관련 쿼리 로직 없이 자동으로 업데이트 된다고 하셨는데요. 주문 생성(OrderService.order)의 EntityManager 가 사용된 orderRepository.save (order);  와 혼동이 와서 질문 남깁니다. 주문 취소 order.cancel() 메서드를 타면서 엔티티의 값(status, count 등) 변경 내역이 자동으로 업데이트 되는 것이라고 하면, 주문 생성도 Order.createOrder(member, delivery, orderItem); 를 타면서 엔티티의 값들을 설정하기 때문에 orderRepository.save (order); 를 사용하지 않아도 되는게 아닌가 라는 생각이 듭니다. 제가 JPA 를 잘 몰라서 혼란이 오는 것 같은데.. 쿼리는 직접 작성하지 않아도 업데이트/저장/삭제 등 DB 조작이 일어나려면 EntityManager 를 통해야 된다고 생각하고 있었습니다. 주문 취소는 EntityManager 없이 업데이트 되고, 주문 생성은 EntityManager의 persist() 를 사용해서 저장하는 것 이 2가지 차이점에 대해서 설명 부탁드립니다! 감사합니다 :)

  • java
  • spring
  • 웹앱
  • spring-boot
  • jpa
빈빈 댓글 1 좋아요 2 조회수 510

data import 덤프 기능

미해결

[리뉴얼] 처음하는 SQL과 데이터베이스(MySQL) 부트캠프 [입문부터 활용까지]

데이터 분석을 위한 환경 구축 (업데이트) 4:27 data import 덤프기능을 사용하는 이유가 궁금합니다 이전에 배웠던대로 student.sql파일로 실행할때처럼 file->open sql.script->student.sql 이런 방식과 차이점이 어떤것인가요? 그리고 create database bestproducts; 를 하기 전 오류가 뜨는 이유와 치면 오류가 왜 사라지는지 궁금합니다

  • python
  • sql
  • mysql
  • dbms/rdbms
  • 데이터-엔지니어링
이하윤 댓글 1 좋아요 0 조회수 293

MYSQL 수강하고 Pandas 강의로 넘어가도 될까요? (몽고DB수강 X)

미해결

[리뉴얼] 처음하는 SQL과 데이터베이스(MySQL) 부트캠프 [입문부터 활용까지]

안녕하세요. 전 열심히 잔재미코딩 선생님 강의 수강하고 있는 수강생입니다. 크롤링 기본,고급 강의 수료했고 지금 열심히 SQL 듣고 있는 중입니다. 이 다음 단계로 MongoDB 건너띄고 판다스 강의로 넘어가도 강의 듣는데 문제없을까요? 조언 부탁드립니다. 감사합니다.

  • python
  • sql
  • mysql
  • dbms/rdbms
  • 데이터-엔지니어링
dostudydo 댓글 1 좋아요 0 조회수 465

fetch함수

미해결

[리뉴얼] 처음하는 SQL과 데이터베이스(MySQL) 부트캠프 [입문부터 활용까지]

패턴으로 익히는 파이썬과 MySQL - 데이터 입력과 검색 9:09 fetch함수는 별도로 테이블을 지정하지않고 데이터베이스만 지정하는 것(fetch앞에있는 cursor로부터) 같은데 그러면 한 데이터베이스에 있는 모든 레코드를 출력해주는 것인가요?

  • python
  • sql
  • mysql
  • dbms/rdbms
  • 데이터-엔지니어링
이하윤 댓글 1 좋아요 0 조회수 444

db.cursor()에서 질문

미해결

[리뉴얼] 처음하는 SQL과 데이터베이스(MySQL) 부트캠프 [입문부터 활용까지]

pymysql 소개 및 설치 14:30 cursor=db.cursor()에서 pymysql을 db앞에 안붙이는 이유는 db안에 pymysql.이 포함되어있기 때문이라고 이해하는 것이 맞나요?

  • python
  • sql
  • mysql
  • dbms/rdbms
  • 데이터-엔지니어링
이하윤 댓글 1 좋아요 0 조회수 264

varchar text 차이

미해결

[리뉴얼] 처음하는 SQL과 데이터베이스(MySQL) 부트캠프 [입문부터 활용까지]

[연습] 실제 데이터 기반, 데이터베이스 직접 만들어보기1 11:55 데이터타입 varchar text 차이가 궁금합니다 ' 그리고 강의내에서 varchar의 경우 int와 달라서 auto_increment를 사용할수없다고 하셨는데 auto_increment는 숫자에만 가능해서 그런건가요?

  • python
  • sql
  • mysql
  • dbms/rdbms
  • 데이터-엔지니어링
이하윤 댓글 1 좋아요 0 조회수 1330

19:04 초 where in 쿼리 대신 where array_conatins 쿼리가 나왔습니다. (스프링 부트 3.1)

해결됨

실전! 스프링 부트와 JPA 활용2 - API 개발과 성능 최적화

[질문 템플릿] 1. 강의 내용과 관련된 질문인가요? (예) 2. 인프런의 질문 게시판과 자주 하는 질문에 없는 내용인가요? (예) 3. 질문 잘하기 메뉴얼을 읽어보셨나요? (예) [질문 내용] 현재 스프링 부트 3.1 로 강의를 따라가고 있습니다. default_batch_fetch_size:10 을 설정해서 나가는 쿼리가 줄어드는 것을 확인했습니다만, 쿼리가 두 개가 아니고 총 세 개가 나왔습니다. 023-06-13T23:24:02.666+09:00 DEBUG 68750 --- [nio-8080-exec-5] org.hibernate.SQL : select o1_0.order_id, d1_0.delivery_id, d1_0.city, d1_0.street, d1_0.zipcode, d1_0.status, m1_0.memeber_id, m1_0.city, m1_0.street, m1_0.zipcode, m1_0.name, o1_0.order_date, o1_0.status from orders o1_0 join member m1_0 on m1_0.memeber_id=o1_0.member_id join delivery d1_0 on d1_0.delivery_id=o1_0.delivery_id offset ? rows fetch first ? rows only 2023-06-13T23:24:02.676+09:00 INFO 68750 --- [nio-8080-exec-5] p6spy : #1686666242676 | took 2ms | statement | connection 8| url jdbc:h2:tcp://localhost/~/springbootjpa select o1_0.order_id,d1_0.delivery_id,d1_0.city,d1_0.street,d1_0.zipcode,d1_0.status,m1_0.memeber_id,m1_0.city,m1_0.street,m1_0.zipcode,m1_0.name,o1_0.order_date,o1_0.status from orders o1_0 join member m1_0 on m1_0.memeber_id=o1_0.member_id join delivery d1_0 on d1_0.delivery_id=o1_0.delivery_id offset ? rows fetch first ? rows only select o1_0.order_id,d1_0.delivery_id,d1_0.city,d1_0.street,d1_0.zipcode,d1_0.status,m1_0.memeber_id,m1_0.city,m1_0.street,m1_0.zipcode,m1_0.name,o1_0.order_date,o1_0.status from orders o1_0 join member m1_0 on m1_0.memeber_id=o1_0.member_id join delivery d1_0 on d1_0.delivery_id=o1_0.delivery_id offset 0 rows fetch first 100 rows only; 2023-06-13T23:24:02.681+09:00 DEBUG 68750 --- [nio-8080-exec-5] org.hibernate.SQL : select o1_0.order_id, o1_0.order_item_id, o1_0.count, o1_0.item_id, o1_0.order_price from order_item o1_0 where array_contains(?,o1_0.order_id) 2023-06-13T23:24:02.689+09:00 INFO 68750 --- [nio-8080-exec-5] p6spy : #1686666242689 | took 0ms | statement | connection 8| url jdbc:h2:tcp://localhost/~/springbootjpa select o1_0.order_id,o1_0.order_item_id,o1_0.count,o1_0.item_id,o1_0.order_price from order_item o1_0 where array_contains(?,o1_0.order_id) select o1_0.order_id,o1_0.order_item_id,o1_0.count,o1_0.item_id,o1_0.order_price from order_item o1_0 where array_contains('ar2: ARRAY [CAST(1 AS BIGINT), CAST(2 AS BIGINT), NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL]',o1_0.order_id); 2023-06-13T23:24:02.690+09:00 DEBUG 68750 --- [nio-8080-exec-5] org.hibernate.SQL : select i1_0.item_id, i1_0.dtype, i1_0.category_item_id, i1_0.name, i1_0.price, i1_0.stock_quantity, i1_0.author, i1_0.isbn, i1_0.artist, i1_0.etc from item i1_0 where array_contains(?,i1_0.item_id) 2023-06-13T23:24:02.691+09:00 INFO 68750 --- [nio-8080-exec-5] p6spy : #1686666242691 | took 0ms | statement | connection 8| url jdbc:h2:tcp://localhost/~/springbootjpa select i1_0.item_id,i1_0.dtype,i1_0.category_item_id,i1_0.name,i1_0.price,i1_0.stock_quantity,i1_0.author,i1_0.isbn,i1_0.artist,i1_0.etc from item i1_0 where array_contains(?,i1_0.item_id) select i1_0.item_id,i1_0.dtype,i1_0.category_item_id,i1_0.name,i1_0.price,i1_0.stock_quantity,i1_0.author,i1_0.isbn,i1_0.artist,i1_0.etc from item i1_0 where array_contains('ar3: ARRAY [CAST(1 AS BIGINT), CAST(2 AS BIGINT), CAST(3 AS BIGINT), CAST(4 AS BIGINT), NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL]',i1_0.item_id); 수강 중에 제가 따라 작성한 코드를 스프링부트 2.4.1에 그대로 옮겨보니 강의 내용대로 where in 쿼리가 나오는 것을 확인했습니다. 스프링부트 버전 차이에서 나오는 쿼리가 달라진 것 같은데, 제 생각이 맞을까요? 답변 확인 : 빠르게 답변해주셔서 감사합니다!! 덕분에 array_contains 로 최적화된 이유를 쉽게 이해할 수 있었습니다. (Hibernate에서 최적화를 했었었군요!) 아 그리고 강의 내용에서 쿼리 세 개 나온다는 것을 확인했습니다(잘못 본 것에 대해 질문글에서 수정을 해놨어야 했는데 빼놓지 않았었네요 ㅠㅠ) 다시 한번 상세한 답변 정말 감사드립니다.

  • java
  • spring
  • spring-boot
  • jpa
말랑한참깨 댓글 1 좋아요 1 조회수 1929

강사님 analytic 집계함수 에 대해서 궁금한게 있습니다.

해결됨

데이터 분석 SQL Fundamentals

select empno, ename, deptno, sal, avg(sal) over (partition by deptno) dept_avg_sal , sal - avg(sal) over (partition by deptno) dept_avg_sal_diff from hr.emp; 위 SQL은 강사님이 작성해주신 코드 입니다. with temp_01 as ( select empno ,ename ,sal as "개인 급여" ,avg(sal) over (partition by deptno) as "평균 급여" from emp ) select empno,ename,"개인 급여","평균 급여",abs("평균 급여"-"개인 급여") from temp_01; 밑에는 제가 답안지를 안보고 먼저 작성한 코드 입니다. 제가 처음에 첫번째 코드처럼 작성을 하려다가 이게 group by 처럼 부하가 좀 큰 작업이라고 생각이되었습니다. 그래서 한번만 사용하고 싶어서 임시테이블을 만들고 그 테이블의 컬럼끼리 계산을 하게 했는데 윈도우 함수를 한번 더 사용하는것과 서브쿼리로 한번만 호출하는 것 중에서 윈도우 함수를 한번 더 호출하는게 더 나은 선택이라면 그 이유가 궁금합니다. 만약에 서브 쿼리를 사용하는데 그 서브 쿼리에 함수를 사용한 컬럼이 있다면 그 컬럼을 호출할때마다 그 함수를 실행해서 그 결과를 가져오나요? 아니면 한번 서브쿼리를 실행하면 그 데이터가 저장되서 값만 가져오나요?

  • sql
  • postgresql
  • dbms/rdbms
cjh 댓글 1 좋아요 0 조회수 350

alter table 명령에서

미해결

[리뉴얼] 처음하는 SQL과 데이터베이스(MySQL) 부트캠프 [입문부터 활용까지]

SQL로 테이블 변경하기 11:34 alter table에서 변경할 컬럼 타입을 넣을때 not null을 안써주면 원래 not null이었으면 null이어도 되는걸로 바뀌는 건가요? 이처럼 변경할 컬럼 타입에 원래 컬럼에 있던 타입에 관련된 것을 안써주면 리셋되는 건가요?

  • python
  • sql
  • mysql
  • dbms/rdbms
  • 데이터-엔지니어링
이하윤 댓글 1 좋아요 0 조회수 324

인기 태그

인프런 TOP Writers

주간 인기글