TIL

10.2 실행 계획 확인

10.2.1 실행 계획 출력 포맷

10.2.2 쿼리의 실행 시간 확인

EXPLAIN ANALYZE
SELECT e.emp_no, avg(s.salary)
FROM employee e
	INNER JOIN salaries s ON s.emp_no=e.emp_no
		AND s.salary>50000
		AND s.from_date<='1990-01-01'
		AND s.to_date>'1990-01-01'
WHERE e.first_name='Matt'
GROUP BY e.hire_date \G

-> Table scan on <templorary> (actual time=0.001..0.004 rows=48 loops=1)
	-> Aggregate using templorary table (actual time=3.779..3.808 rows=48 loops=1)
		-> Nested loop inner join (cost=685.24 rows=135)
					(actual time=0.367...3.602 rows=48 loops=1)
			-> Index lookup on e using ix_firstname (first_name='Matt') (cost=215.08 rows=233)
					(actual time=0.348..1.046 rows-233 loops=1)
			-> Filter: ((s.salary>50000) and (s.from_date<=DATE'1990-0101')
								and (s.to_date>DATE'1990'01-01')) (cost=0.98 rows=1)
					(actual time=0.009..0.011 rows=0 loops=233)
				-> Index loopup on s using PRIMARY (emp_no=e.emp_no) (cost=0.98 rows=10)
					(actual time=0.007..0.009 rows-10 loops=233)