OR보다는 IN이 더 빠르다는군요 > db

본문 바로가기
사이트 내 전체검색

db

OR보다는 IN이 더 빠르다는군요

페이지 정보

작성자 서방님 댓글 0건 조회 140회 작성일 06-09-13 11:23

본문

내용의 확실한 전달을 위해서 원문을 그대로 실었습니다.
참고하세요.. ^^;

Tip 1: 
In sql, it's actually faster (and easier) to use an 'In' clause,
rather than lots of OR something = this OR something = that. Ex.. 

SELECT * FROM Cars WHERE Model = 'Ford' OR Model = 'GM' OR Model = 'Chrysler' 

This is faster (and more readable): 

SELECT * FROM Cars WHERE Model In ('Ford', 'GM', 'Chrysler') 

Tip 2: 
Although at first, they may seem slightly complex (for some people just starting to use sql),
try to use INNER JOINs as they are faster than embedded sql statements. Ex. 

SELECT * FROM Cars WHERE Color In (SELECT Color FROM Color_Palette) 

This is faster: 

SELECT * FROM Cars INNER JOIN Color_Palette ON Cars.Color = Color_Palette.Color 

자료출처 : http://www.devpia.com/Forum/BoardView.aspx?no=446&page=13&Tpage=18&forumname=sql_lec&stype=&ctType=

댓글목록

등록된 댓글이 없습니다.

Total 464건 29 페이지
게시물 검색

회원로그인

접속자집계

오늘
31
어제
302
최대
1,347
전체
155,092
Latest Crypto Fear & Greed Index

그누보드5
Copyright © 서방님.kr All rights reserved.