Download - 활용예시를 통한 Sql server 2012의 향상된 프로그래밍 기능 엿보기
![Page 1: 활용예시를 통한 Sql server 2012의 향상된 프로그래밍 기능 엿보기](https://reader033.vdocuments.pub/reader033/viewer/2022042715/559664481a28abe7338b4739/html5/thumbnails/1.jpg)
활용예시를 통한 SQL Server 2012 의 향상된 프로그래밍 기능 엿보기
DB팀임현수
![Page 2: 활용예시를 통한 Sql server 2012의 향상된 프로그래밍 기능 엿보기](https://reader033.vdocuments.pub/reader033/viewer/2022042715/559664481a28abe7338b4739/html5/thumbnails/2.jpg)
개요 향상된 프로그래밍 기능 Part 1
- 페이징 (O FFS ET/FETC H )
- 효율적인 채번 (S EQ U ENC E)
- 경험치 비교 (Analytic Func tio ns )
향상된 프로그래밍 기능 Part 2 - 집계처리 가속화 (C o lum nS to re Ind e x)
- 쿼리분석기 1 20% 활용 - 유용한 함수마무리
![Page 3: 활용예시를 통한 Sql server 2012의 향상된 프로그래밍 기능 엿보기](https://reader033.vdocuments.pub/reader033/viewer/2022042715/559664481a28abe7338b4739/html5/thumbnails/3.jpg)
개요
![Page 4: 활용예시를 통한 Sql server 2012의 향상된 프로그래밍 기능 엿보기](https://reader033.vdocuments.pub/reader033/viewer/2022042715/559664481a28abe7338b4739/html5/thumbnails/4.jpg)
S Q L S e rve r 2005 2008 R2~ 향상된 프로그래밍 기능
- RANK () O VER
- RO W_NU MBER () O VER
- C TE
- MERGE
- F ilte re d In d e x
![Page 5: 활용예시를 통한 Sql server 2012의 향상된 프로그래밍 기능 엿보기](https://reader033.vdocuments.pub/reader033/viewer/2022042715/559664481a28abe7338b4739/html5/thumbnails/5.jpg)
SQL Server 2012 향상된 프로그래밍 기능 Part 1
![Page 6: 활용예시를 통한 Sql server 2012의 향상된 프로그래밍 기능 엿보기](https://reader033.vdocuments.pub/reader033/viewer/2022042715/559664481a28abe7338b4739/html5/thumbnails/6.jpg)
페이징 (FETCH/OFFSET)
![Page 7: 활용예시를 통한 Sql server 2012의 향상된 프로그래밍 기능 엿보기](https://reader033.vdocuments.pub/reader033/viewer/2022042715/559664481a28abe7338b4739/html5/thumbnails/7.jpg)
페이징 (ro w_num b e r())
select x.*from (
select top ( @PageNo * @PageSize)
, row_number() over (order by col01 ) seqNo, col01, col02from dbo.tab01 with (readuncommitted)where col01 > @startArticleNoorder by col01 ) x
where x.seqNo between (@PageNo-1) * @PageSize and @PageNo * @PageSize -1order by x.col01;
B efore
![Page 8: 활용예시를 통한 Sql server 2012의 향상된 프로그래밍 기능 엿보기](https://reader033.vdocuments.pub/reader033/viewer/2022042715/559664481a28abe7338b4739/html5/thumbnails/8.jpg)
페이징 (O FFS ET/FETC H )
select * from dbo.tab01 wtih (nolock) where col01 >= @startArticleNoorder by col01 offset (@PageNo-1)*@PageSize rowsfetch next @PageSize rows only;
After
![Page 9: 활용예시를 통한 Sql server 2012의 향상된 프로그래밍 기능 엿보기](https://reader033.vdocuments.pub/reader033/viewer/2022042715/559664481a28abe7338b4739/html5/thumbnails/9.jpg)
페이징 (정리 )
항목 Row_number() OFFSET/FETCH
구문 복잡도 복잡 (11 lines) 단순 (6 lines)
성능 I/O 부하 동일
의견 성능 개선효과는 없으나 , 개발생산성 증대
![Page 10: 활용예시를 통한 Sql server 2012의 향상된 프로그래밍 기능 엿보기](https://reader033.vdocuments.pub/reader033/viewer/2022042715/559664481a28abe7338b4739/html5/thumbnails/10.jpg)
효율적인 채번 (Sequence)
![Page 11: 활용예시를 통한 Sql server 2012의 향상된 프로그래밍 기능 엿보기](https://reader033.vdocuments.pub/reader033/viewer/2022042715/559664481a28abe7338b4739/html5/thumbnails/11.jpg)
효율적인 채번 ( 임시 테이블 )
-- 임시테이블 생성create table SeqNo_tab (SeqNo int);Insert into SeqNo_tab values (1);
-- 채번 성능 테스트declare @seqval int = 0, @cnt int = 0; while (@cnt <= 1000000)begin update SeqNo_tab set @seqval= SeqNo = SeqNo + 1; set @Cnt = @Cnt + 1;end
B efore
![Page 12: 활용예시를 통한 Sql server 2012의 향상된 프로그래밍 기능 엿보기](https://reader033.vdocuments.pub/reader033/viewer/2022042715/559664481a28abe7338b4739/html5/thumbnails/12.jpg)
효율적인 채번 (S e q ue nc e )
-- 시퀀스 생성Create sequence SeqNo_cache10Start with 1Increment by 1 Cache 10;go -- 채번 성능 테스트declare @seqval int = 0, @Cnt int = 0;
while (@Cnt <= 1000000)begin
SELECT @seqval = next value for SeqNo_cache10;set @Cnt = @Cnt + 1;
end
After
![Page 13: 활용예시를 통한 Sql server 2012의 향상된 프로그래밍 기능 엿보기](https://reader033.vdocuments.pub/reader033/viewer/2022042715/559664481a28abe7338b4739/html5/thumbnails/13.jpg)
효율적인 채번 (정리 )
항목 임시테이블 SEQUENCE
구문 복잡도 유사
성능(100만건 )
3 분 49초 21 초 (Nocache) or9 초 (Cache)
의견 약 25 배 성능 개선 , 범위 처리 함수 제공
![Page 14: 활용예시를 통한 Sql server 2012의 향상된 프로그래밍 기능 엿보기](https://reader033.vdocuments.pub/reader033/viewer/2022042715/559664481a28abe7338b4739/html5/thumbnails/14.jpg)
경험치 비교 (Analytic Functions)
![Page 15: 활용예시를 통한 Sql server 2012의 향상된 프로그래밍 기능 엿보기](https://reader033.vdocuments.pub/reader033/viewer/2022042715/559664481a28abe7338b4739/html5/thumbnails/15.jpg)
경험치 비교
![Page 16: 활용예시를 통한 Sql server 2012의 향상된 프로그래밍 기능 엿보기](https://reader033.vdocuments.pub/reader033/viewer/2022042715/559664481a28abe7338b4739/html5/thumbnails/16.jpg)
경험치 비교 (s e lf jo in )
select a.seqNo, a.CompareValue, b.CompareValuefrom tab_01 a with (readuncommitted)left outer join tab_01 b with (readuncommitted) on a.seqNo -1 = b.seqNoorder by a.seqNo
42 pages
B efore
![Page 17: 활용예시를 통한 Sql server 2012의 향상된 프로그래밍 기능 엿보기](https://reader033.vdocuments.pub/reader033/viewer/2022042715/559664481a28abe7338b4739/html5/thumbnails/17.jpg)
경험치 비교 (Analytic Func tio n : LAG)
selectseqNo
, compareValue , lag(compareValue, 1, 0) over (order by seqNo) as LagValuefrom tab_01 with (readuncommitted) order by seqNo
2 pages
After
![Page 18: 활용예시를 통한 Sql server 2012의 향상된 프로그래밍 기능 엿보기](https://reader033.vdocuments.pub/reader033/viewer/2022042715/559664481a28abe7338b4739/html5/thumbnails/18.jpg)
경험치 비교 (정리 )
항목 Self join Analytic Func (LAG)
구문 복잡도 유사
성능 42 pages 2 pages
의견 약 21 배 성능 개선 , 활용 빈도는 낮으나 매우 유용함
![Page 19: 활용예시를 통한 Sql server 2012의 향상된 프로그래밍 기능 엿보기](https://reader033.vdocuments.pub/reader033/viewer/2022042715/559664481a28abe7338b4739/html5/thumbnails/19.jpg)
SQL Server 2012 향상된 프로그래밍 기능 Part 2
![Page 20: 활용예시를 통한 Sql server 2012의 향상된 프로그래밍 기능 엿보기](https://reader033.vdocuments.pub/reader033/viewer/2022042715/559664481a28abe7338b4739/html5/thumbnails/20.jpg)
집계 쿼리 가속화 (ColumnStore Idx)
![Page 21: 활용예시를 통한 Sql server 2012의 향상된 프로그래밍 기능 엿보기](https://reader033.vdocuments.pub/reader033/viewer/2022042715/559664481a28abe7338b4739/html5/thumbnails/21.jpg)
집계 쿼리 가속화 (C o lum nS to re Ind e x)
![Page 22: 활용예시를 통한 Sql server 2012의 향상된 프로그래밍 기능 엿보기](https://reader033.vdocuments.pub/reader033/viewer/2022042715/559664481a28abe7338b4739/html5/thumbnails/22.jpg)
집계 쿼리 가속화 (정리 )
항목 Rowstore Index Columnstore Index
용량 1,500 MB 270 MB
성능(3500만건 )
1 분 19초 0초
의견 집계를 위한 최적의 솔루션임 .Columnstore Index 있는 경우 DML 사용 불가
![Page 23: 활용예시를 통한 Sql server 2012의 향상된 프로그래밍 기능 엿보기](https://reader033.vdocuments.pub/reader033/viewer/2022042715/559664481a28abe7338b4739/html5/thumbnails/23.jpg)
쿼리분석기 120% 활용 (SSMS)
![Page 24: 활용예시를 통한 Sql server 2012의 향상된 프로그래밍 기능 엿보기](https://reader033.vdocuments.pub/reader033/viewer/2022042715/559664481a28abe7338b4739/html5/thumbnails/24.jpg)
ZO O M 기능
![Page 25: 활용예시를 통한 Sql server 2012의 향상된 프로그래밍 기능 엿보기](https://reader033.vdocuments.pub/reader033/viewer/2022042715/559664481a28abe7338b4739/html5/thumbnails/25.jpg)
쿼리창 분리
![Page 26: 활용예시를 통한 Sql server 2012의 향상된 프로그래밍 기능 엿보기](https://reader033.vdocuments.pub/reader033/viewer/2022042715/559664481a28abe7338b4739/html5/thumbnails/26.jpg)
유용한 함수
![Page 27: 활용예시를 통한 Sql server 2012의 향상된 프로그래밍 기능 엿보기](https://reader033.vdocuments.pub/reader033/viewer/2022042715/559664481a28abe7338b4739/html5/thumbnails/27.jpg)
유용한 함수카테고리 함수 설명
날짜함수EMONTH() 해당월의 마지막 날짜 반환
FORMAT()날짜 /시간 , 숫자값을 원하는 포맷으로변환
비교함수IIF() CASE 구문과 동일한 기능
CHOOSE() Index 위치의 변수값을 돌려주는 구문
문자열함수CONCAT()
함수내의 문자열을 하나의 문장으로 연결
TRY_CONVERT() 문자열 -> 날짜로 전환이 가능한지 확인
![Page 28: 활용예시를 통한 Sql server 2012의 향상된 프로그래밍 기능 엿보기](https://reader033.vdocuments.pub/reader033/viewer/2022042715/559664481a28abe7338b4739/html5/thumbnails/28.jpg)
마무리 기본기(모델링 , SQL)
활용능력(SQL Server,
Oracle)