34 EXPLAIN ANALYZE SELECT e.empno,d.dname,s.gradeFROM emp e JOIN dept d ON e.deptno=d.deptno JOIN salgrade s on e.sal between s.losal and s.hisal where e.job='SALESMAN'; Column | Type ----------+----------------------------- empno | integer ename | character varying(10) job | character varying(9) mgr | integer hiredate | timestamp without time zone sal | integer comm | integer deptno | integer EMP表 Column | Type --------+----------------------- deptno | integer dname | character varying(14) loc | character varying(13) DEPT表 Column | Type --------+--------- grade | integer losal | integer hisal | integer SALGRADE表 4.切り札!EXPLAIN
34.
35 Nested Loop (cost=0.00..7.85 rows=1width=50) (actual time=0.031..0.089 rows=4 loops=1) Join Filter: ((emp.sal >= s.losal) AND (emp.sal <= s.hisal)) Rows Removed by Join Filter: 16 -> Nested Loop (cost=0.00..5.67 rows=1 width=54) (actual time=0.027..0.060 rows=4 loops=1) Join Filter: (emp.deptno = d.deptno) Rows Removed by Join Filter: 12 -> Seq Scan on emp (cost=0.00..1.18 rows=1 width=12) (actual time=0.014..0.020 rows=4 loops=1) Filter: ((job)::text = 'SALESMAN'::text) Rows Removed by Filter: 10 -> Seq Scan on dept d (cost=0.00..1.05 rows=4 width=50) (actual time=0.001..0.003 rows=4 loops=4) -> Seq Scan on salgrade s (cost=0.00..1.04 rows=5 width=8) (actual time=0.001..0.002 rows=5 loops=4) ① ② ③ ④ ⑤ 4.切り札!EXPLAIN 出力結果
35.
36 実行結果をツリーにすると Seq Scan onemp cost=1.18 time=0.020 Seq Scan on dept d cost=1.05 time=0.003 x 4 Nested Loop cost=5.67 time=0.060 Seq Scan on salgrade s cost=1.04 time= 0.002 x 4 Nested Loop cost=7.85 time=0.089