By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0.
Help with an interesting Postgres question: Why isn't an Index Only Scan used on a partition accessed via the parent table?.
SELECT 14
ALTER TABLE
ALTER TABLE
empno | ename | mgr |
---|---|---|
7839 | KING | null |
SELECT 1
empno | ename | mgr |
---|---|---|
7839 | KING | null |
SELECT 1
empno | ename | mgr | mgr_name |
---|---|---|---|
7566 | JONES | 7839 | KING |
7698 | BLAKE | 7839 | KING |
7782 | CLARK | 7839 | KING |
SELECT 3
empno | ename | mgr | mgr |
---|---|---|---|
7839 | KING | null | |
7566 | JONES | 7839 | KING |
7698 | BLAKE | 7839 | KING |
7782 | CLARK | 7839 | KING |
SELECT 4
empno | ename | mgr | mgr |
---|---|---|---|
7839 | KING | null | |
7566 | JONES | 7839 | KING |
7698 | BLAKE | 7839 | KING |
7782 | CLARK | 7839 | KING |
7499 | ALLEN | 7698 | BLAKE |
7521 | WARD | 7698 | BLAKE |
7654 | MARTIN | 7698 | BLAKE |
7788 | SCOTT | 7566 | JONES |
7844 | TURNER | 7698 | BLAKE |
7900 | JAMES | 7698 | BLAKE |
7902 | FORD | 7566 | JONES |
7934 | MILLER | 7782 | CLARK |
7369 | SMITH | 7902 | FORD |
7876 | ADAMS | 7788 | SCOTT |
SELECT 14
QUERY PLAN |
---|
CTE Scan on leveln (cost=19.34..21.36 rows=101 width=72) |
CTE leveln |
-> Recursive Union (cost=0.00..19.34 rows=101 width=72) |
-> Seq Scan on emp (cost=0.00..1.14 rows=1 width=72) |
Filter: (mgr IS NULL) |
-> Hash Join (cost=0.33..1.62 rows=10 width=72) |
Hash Cond: (emp_1.mgr = mgr.empno) |
-> Seq Scan on emp emp_1 (cost=0.00..1.14 rows=14 width=40) |
-> Hash (cost=0.20..0.20 rows=10 width=36) |
-> WorkTable Scan on leveln mgr (cost=0.00..0.20 rows=10 width=36) |
EXPLAIN