You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
SELECT*FROM test WHERE age ='2'; -- NUMBER 타입에 문자열 사용 XSELECT*FROM test WHERE age =2;
범위 조건 비교 시 인덱스 사용 (WHERE, ORDER BY)
범위 조건 비교 시 조건을 만족하는 칼럼의 값이 여러개일 수 있기 때문에 누락 X
index: col_1, col_2, col_3, col_4, col_5
-- 인덱스 사용 가능
... WHERE col_1=10ORDER BY col_2, col_3;
... WHERE col_1=10ORDER BY col_1, col_2, col_3;
... WHERE col_1>10ORDER BY col_1, col_2, col_3;
-- 인덱스 사용 불가능 SELECT*FROM tb_test WHERE col_1>10ORDER BY col_2, col_3; -- 사용 불가
문자열, 날짜 비교
(1), (2)는 모두 인덱스를 효율적으로 이용
(3)은 조건의 hire_date 타입을 강제로 변환하기 때문에 인덱스를 효율적으로 이용하지 못함
(1) mysql> ... WHERE hire_date>STR_TO_DATE('2023-03-13', '%Y-%m-%d');
(2) mysql> ... WHERE hire_date>'2023-03-13';
(3) mysql> ... WHERE DATE_FORMAT(hire_date, '%Y-%m-%d') >'2023-03-13';
mysql >SELECTCOUNT(*) FROM salaries;
->COUNT(*) =2844047-- 1번 조건
mysql >SELECTCOUNT(*) FROM salaries
WHERE CONVERT_TZ(from_date, '+00:00', '+09:00')>'1991-01-01')
->COUNT(*) =2442943-- 2번 조건
mysql >SELECTCOUNT(*) FROM salaries WHERE to_date<'1985-01-01';
->COUNT(*) =0
NOT IN
NOT IN은 안티 세미 조인 ... 가능하면 다른 조건으로 변경하고 사용하지 말 것
The text was updated successfully, but these errors were encountered:
The text was updated successfully, but these errors were encountered: