티스토리 뷰
where절 조건 검색을 위해서 case then 을 사용할 경우 성능 저하 문제점
1. index를 사용할 수 없다. index를 사용할 수 없다는 말은 (풀 스캔)을 한다는 말이다.
2. 실행 계획을 재사용할 수 없다. DBMS는 쿼리 실행 후 실행 계획을 만들어 재사용한다. 하지만
where 절에 case문을 사용할 경우 실행 계획을 재사용할 수 없다.
select
CC.CUST_NO
,CA.NATION_CD as ca_nation_cd
from customer.DBO.AA CC with(nolock)
inner join customer.DBO.AA CA with(nolock)
on CC.CUST_NO = CA.CUST_NO
and CA.default_yn = 'Y'
where 1 = (select case when @search_type = 'id' then 1 else 0 end)
and cc.member_kind = 'J'
and cc.partner_cust_id = @search_word
union
select
CC.CUST_NO
,CA.NATION_CD as ca_nation_cd
from customer.DBO.AA CC with(nolock)
inner join customer.DBO.AA CA with(nolock)
on CC.CUST_NO = CA.CUST_NO
and CA.default_yn = 'Y'
where 1 = (select case when @search_type = 'no' then 1 else 0 end)
and cc.member_kind = 'J'
and cc.partner_cust_no = @search_word
---------------------------------------------------------------------------------
and 조건 사용
and
(
(@onoff = '' and 1=1)
or
(@onoff <> '' and CC.IS_CONFIRM = @onoff)
)
- Total
- Today
- Yesterday
- React
- 스프링 프레임워크(spring framework)
- jstl(java standard tag library)-core
- java 키워드 정리
- 스프링 시큐리티(spring security)
- 특정 문자를 기준으로 자르기
- 진수 변환
- 제품 등록
- 인텔리제이(intellij)
- jsp 오픈 소스
- 메이븐(maven)
- java-개발 환경 설정하기
- REST API
- java.sql
- error-java
- system.io
- .submit()
- 스프링 시큐리티(spring security)-http basic 인증
- 표현 언어(expression language)
- 스프링 프레임워크(spring framewordk)
- docker
- jstl(java standard tag library)
- MainActor
- nl2br
- 람다식(lambda expression)
- 문자 자르기
- In App Purchase
- java web-mvc
- System.Diagnostics
- await
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |