SlideShare a Scribd company logo
1 of 10
나라면 데이터를 어떻게 처리할까?
- 옵티마이저 입장에서 SQL 처리하는 방식으로……
• 자바카페 & 저의 소개
• 옵티마이저란?
• 그룹함수 사용
• 인덱스 + 컬럼가공
• 마치며..
정재욱
자바카페와 발표자 소개
• 스터디를 위해 모인 사람들!!!
- offline으로 만나서 스터디를...
- 월마다 정기회의도 하고~
- onoffmix or facebook을 통해 공지
- 공식/비공식 진행
- java에서 다양한 관심 분야로~
저의 2012년 첫 스터디 모임 그룹
2012년 3월 10일 첫 스터디 모임 OT 참석
Optimizer란? <도서관>
<임시보관소>
<경비초소>
그룹함수 사용에서..
(1)
SELECT
B.색이름
, COUNT(*) AS 건수
FROM
색깔상자 A
, 색코드표 B
WHERE B.색ID = A.색ID
GROUP BY
B.색이름
(2)
SELECT
B.색이름
, A.건수
FROM
( SELECT
색ID
, COUNT(*) AS 건수
FROM
색깔상자
GROUP BY
색ID
) A
, 색코드표 B
WHERE B.색ID = A.색ID
(3)
SELECT
(SELECT 색이름 FROM 색코드표
WHERE 색ID = A.색ID) AS 색이름
, COUNT(*) AS 건수
FROM
색깔상자 A
GROUP BY
색ID
<< 색깔상자에서 색 칠해야 하는 띠들이 얼마나 있는지 확인해야 하는 쿼리 >>
그룹함수 사용에서..
색깔상자
색코드표
A01 빨간색
A02 파란색
A03 초록색
… …
A01
그룹함수 사용에서..
A01
A01
A03
A02
A01
(1)번 SQL이 처리하는 방식
A01 A02
그룹함수 사용에서..
A01
A01
A03
A03
A03
A02
A02
A01
A01
(2, 3)번 SQL이 처리하는 방식
인덱스는..
판매날짜 상품ID
20180601 P010492
20180601 P020421
20180602 P011123
20180602 P011234
20180602 P015236
20180603 P382733
…. ….
SELECT
*
FROM
판매내역
WHERE 판매날짜 = '20180609'
AND 상품ID LIKE 'P091%'
SELECT
*
FROM
판매내역
WHERE 판매날짜 BETWEEN '20180601' AND '20180609'
AND 상품ID = 'P09131'
상품ID 판매날짜
P010492 20180601
P011123 20180602
P011234 20180602
P015236 20180602
P016784 20180607
P020421 20180601
…. ….
SELECT
*
FROM
판매내역
WHERE 판매날짜 IN ( '20180601'
, '20180602'
, '20180603'
, '20180604'
, '20180605'
, '20180606'
, '20180607'
, '20180608'
, '20180609' )
AND 상품ID = 'P09131'
WHERE 컬럼 사용에 주의할 점..
SELECT
*
FROM
판매내역
WHERE TO_CHAR(판매날짜, 'YYYYMMDD') =
'20180609'
AND 상품ID LIKE 'P091%'
SELECT
*
FROM
판매내역
WHERE 판매날짜 = '20180609'
AND SUBSTR(상품ID, 1, 4) = 'P091'
SELECT
*
FROM
판매내역
WHERE 판매날짜 = TO_DATE('20180609' ,
'YYYYMMDD')
AND 상품ID LIKE 'P091%'
SELECT
*
FROM
판매내역
WHERE 판매날짜 = '20180609'
AND 상품ID LIKE 'P091%'
(1) CHARACTER < NUMBER (2) CHARACTER < DATE
'1111'  TO_NUMBER('1111') '20180609'  TO_DATE('20180609', 'YYYYMMDD')
출처
• 2012년 사진첩(발표자)
• 구글에 이미지 명칭 검색(도서관, 움막집, 초소 등)
알아두면 도움이 될 용어들
• Scalar Sub-query, In-line view Sub-query, Sub-query
• 부분범위 vs. 전체범위 처리
• Nested loop, Hash, (Sort) Merge
• Random I/O

More Related Content

Recently uploaded

Grid Layout (Kitworks Team Study 장현정 발표자료)
Grid Layout (Kitworks Team Study 장현정 발표자료)Grid Layout (Kitworks Team Study 장현정 발표자료)
Grid Layout (Kitworks Team Study 장현정 발표자료)
Wonjun Hwang
 

Recently uploaded (7)

캐드앤그래픽스 2024년 5월호 목차
캐드앤그래픽스 2024년 5월호 목차캐드앤그래픽스 2024년 5월호 목차
캐드앤그래픽스 2024년 5월호 목차
 
도심 하늘에서 시속 200km로 비행할 수 있는 미래 항공 모빌리티 'S-A2'
도심 하늘에서 시속 200km로 비행할 수 있는 미래 항공 모빌리티 'S-A2'도심 하늘에서 시속 200km로 비행할 수 있는 미래 항공 모빌리티 'S-A2'
도심 하늘에서 시속 200km로 비행할 수 있는 미래 항공 모빌리티 'S-A2'
 
MOODv2 : Masked Image Modeling for Out-of-Distribution Detection
MOODv2 : Masked Image Modeling for Out-of-Distribution DetectionMOODv2 : Masked Image Modeling for Out-of-Distribution Detection
MOODv2 : Masked Image Modeling for Out-of-Distribution Detection
 
Grid Layout (Kitworks Team Study 장현정 발표자료)
Grid Layout (Kitworks Team Study 장현정 발표자료)Grid Layout (Kitworks Team Study 장현정 발표자료)
Grid Layout (Kitworks Team Study 장현정 발표자료)
 
[Terra] Terra Money: Stability and Adoption
[Terra] Terra Money: Stability and Adoption[Terra] Terra Money: Stability and Adoption
[Terra] Terra Money: Stability and Adoption
 
Continual Active Learning for Efficient Adaptation of Machine LearningModels ...
Continual Active Learning for Efficient Adaptation of Machine LearningModels ...Continual Active Learning for Efficient Adaptation of Machine LearningModels ...
Continual Active Learning for Efficient Adaptation of Machine LearningModels ...
 
A future that integrates LLMs and LAMs (Symposium)
A future that integrates LLMs and LAMs (Symposium)A future that integrates LLMs and LAMs (Symposium)
A future that integrates LLMs and LAMs (Symposium)
 

Featured

How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
ThinkNow
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
Kurio // The Social Media Age(ncy)
 

Featured (20)

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 

20180609 sql presentation

  • 1. 나라면 데이터를 어떻게 처리할까? - 옵티마이저 입장에서 SQL 처리하는 방식으로…… • 자바카페 & 저의 소개 • 옵티마이저란? • 그룹함수 사용 • 인덱스 + 컬럼가공 • 마치며.. 정재욱
  • 2. 자바카페와 발표자 소개 • 스터디를 위해 모인 사람들!!! - offline으로 만나서 스터디를... - 월마다 정기회의도 하고~ - onoffmix or facebook을 통해 공지 - 공식/비공식 진행 - java에서 다양한 관심 분야로~ 저의 2012년 첫 스터디 모임 그룹 2012년 3월 10일 첫 스터디 모임 OT 참석
  • 4. 그룹함수 사용에서.. (1) SELECT B.색이름 , COUNT(*) AS 건수 FROM 색깔상자 A , 색코드표 B WHERE B.색ID = A.색ID GROUP BY B.색이름 (2) SELECT B.색이름 , A.건수 FROM ( SELECT 색ID , COUNT(*) AS 건수 FROM 색깔상자 GROUP BY 색ID ) A , 색코드표 B WHERE B.색ID = A.색ID (3) SELECT (SELECT 색이름 FROM 색코드표 WHERE 색ID = A.색ID) AS 색이름 , COUNT(*) AS 건수 FROM 색깔상자 A GROUP BY 색ID << 색깔상자에서 색 칠해야 하는 띠들이 얼마나 있는지 확인해야 하는 쿼리 >>
  • 8. 인덱스는.. 판매날짜 상품ID 20180601 P010492 20180601 P020421 20180602 P011123 20180602 P011234 20180602 P015236 20180603 P382733 …. …. SELECT * FROM 판매내역 WHERE 판매날짜 = '20180609' AND 상품ID LIKE 'P091%' SELECT * FROM 판매내역 WHERE 판매날짜 BETWEEN '20180601' AND '20180609' AND 상품ID = 'P09131' 상품ID 판매날짜 P010492 20180601 P011123 20180602 P011234 20180602 P015236 20180602 P016784 20180607 P020421 20180601 …. …. SELECT * FROM 판매내역 WHERE 판매날짜 IN ( '20180601' , '20180602' , '20180603' , '20180604' , '20180605' , '20180606' , '20180607' , '20180608' , '20180609' ) AND 상품ID = 'P09131'
  • 9. WHERE 컬럼 사용에 주의할 점.. SELECT * FROM 판매내역 WHERE TO_CHAR(판매날짜, 'YYYYMMDD') = '20180609' AND 상품ID LIKE 'P091%' SELECT * FROM 판매내역 WHERE 판매날짜 = '20180609' AND SUBSTR(상품ID, 1, 4) = 'P091' SELECT * FROM 판매내역 WHERE 판매날짜 = TO_DATE('20180609' , 'YYYYMMDD') AND 상품ID LIKE 'P091%' SELECT * FROM 판매내역 WHERE 판매날짜 = '20180609' AND 상품ID LIKE 'P091%' (1) CHARACTER < NUMBER (2) CHARACTER < DATE '1111'  TO_NUMBER('1111') '20180609'  TO_DATE('20180609', 'YYYYMMDD')
  • 10. 출처 • 2012년 사진첩(발표자) • 구글에 이미지 명칭 검색(도서관, 움막집, 초소 등) 알아두면 도움이 될 용어들 • Scalar Sub-query, In-line view Sub-query, Sub-query • 부분범위 vs. 전체범위 처리 • Nested loop, Hash, (Sort) Merge • Random I/O