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?.
4 rows affected
id | level_title | quiz_desc | overall_quest |
---|---|---|---|
1 | Sets | The purpose of... | Suppose we have... |
2 | Seqs | sequences desc... | overall question... |
3 | Prop Logic | logic desc ... | overall quest... |
4 | Pred Logic | pred desc 1 ... | predicase quest... |
10 rows affected
id | level_title | quiz_desc | overall_quest | student_no | level_id | points | ts |
---|---|---|---|---|---|---|---|
1 | Sets | The purpose of... | Suppose we have... | 40204123 | 1 | 80 | 2021-01-12 15:37:11 |
2 | Seqs | sequences desc... | overall question... | 40204123 | 2 | 75 | 2021-01-12 15:38:06 |
3 | Prop Logic | logic desc ... | overall quest... | 40204123 | 3 | 30 | 2021-01-13 22:13:13 |
id | level_title | quiz_desc | overall_quest | student_no | level_id | points | ts |
---|---|---|---|---|---|---|---|
1 | Sets | The purpose of... | Suppose we have... | 40204123 | 1 | 80 | 2021-01-12 15:37:11 |
2 | Seqs | sequences desc... | overall question... | 40204123 | 2 | 75 | 2021-01-12 15:38:06 |
3 | Prop Logic | logic desc ... | overall quest... | 40204123 | 3 | 30 | 2021-01-13 22:13:13 |
4 | Pred Logic | pred desc 1 ... | predicase quest... | null | null | null | null |
id | level_title | quiz_desc | overall_quest | student_no | level_id | points | ts |
---|---|---|---|---|---|---|---|
1 | Sets | The purpose of... | Suppose we have... | 40204123 | 1 | 80 | 2021-01-12 15:37:11 |
2 | Seqs | sequences desc... | overall question... | 40204123 | 2 | 75 | 2021-01-12 15:38:06 |
3 | Prop Logic | logic desc ... | overall quest... | 40204123 | 3 | 30 | 2021-01-13 22:13:13 |
1 | Sets | The purpose of... | Suppose we have... | 40213894 | 1 | 90 | 2021-01-14 21:52:00 |
2 | Seqs | sequences desc... | overall question... | 40213894 | 2 | 95 | 2021-01-17 22:42:50 |
4 | Pred Logic | pred desc 1 ... | predicase quest... | 40213894 | 4 | 100 | 2021-01-17 22:42:50 |
id | level_title | quiz_desc | overall_quest | student_no | level_id | points | ts |
---|---|---|---|---|---|---|---|
1 | Sets | The purpose of... | Suppose we have... | 40204123 | 1 | 80 | 2021-01-12 15:37:11 |
2 | Seqs | sequences desc... | overall question... | 40204123 | 2 | 75 | 2021-01-12 15:38:06 |
3 | Prop Logic | logic desc ... | overall quest... | 40204123 | 3 | 30 | 2021-01-13 22:13:13 |
1 | Sets | The purpose of... | Suppose we have... | 40213894 | 1 | 90 | 2021-01-14 21:52:00 |
2 | Seqs | sequences desc... | overall question... | 40213894 | 2 | 95 | 2021-01-17 22:42:50 |
4 | Pred Logic | pred desc 1 ... | predicase quest... | 40213894 | 4 | 100 | 2021-01-17 22:42:50 |
id | level_title | quiz_desc | overall_quest | student_no | level_id | points | ts |
---|---|---|---|---|---|---|---|
1 | Sets | The purpose of... | Suppose we have... | 40204123 | 1 | 80 | 2021-01-12 15:37:11 |
1 | Sets | The purpose of... | Suppose we have... | 40204123 | 2 | 75 | 2021-01-12 15:38:06 |
1 | Sets | The purpose of... | Suppose we have... | 40204123 | 3 | 30 | 2021-01-13 22:13:13 |
2 | Seqs | sequences desc... | overall question... | 40204123 | 1 | 80 | 2021-01-12 15:37:11 |
2 | Seqs | sequences desc... | overall question... | 40204123 | 2 | 75 | 2021-01-12 15:38:06 |
2 | Seqs | sequences desc... | overall question... | 40204123 | 3 | 30 | 2021-01-13 22:13:13 |
3 | Prop Logic | logic desc ... | overall quest... | 40204123 | 1 | 80 | 2021-01-12 15:37:11 |
3 | Prop Logic | logic desc ... | overall quest... | 40204123 | 2 | 75 | 2021-01-12 15:38:06 |
3 | Prop Logic | logic desc ... | overall quest... | 40204123 | 3 | 30 | 2021-01-13 22:13:13 |
4 | Pred Logic | pred desc 1 ... | predicase quest... | 40204123 | 1 | 80 | 2021-01-12 15:37:11 |
4 | Pred Logic | pred desc 1 ... | predicase quest... | 40204123 | 2 | 75 | 2021-01-12 15:38:06 |
4 | Pred Logic | pred desc 1 ... | predicase quest... | 40204123 | 3 | 30 | 2021-01-13 22:13:13 |
ERROR: syntax error at or near "1"
LINE 5: 1 Sets The purpose of Suppose we have 40204...
^
l_id | l_title | l_q_desc | l_o_quest | s_no | s_l_id | coalesce | s_ts |
---|---|---|---|---|---|---|---|
1 | Sets | The purpose of... | Suppose we have... | 40204123 | 1 | 80 | 2021-01-12 15:37:11 |
2 | Seqs | sequences desc... | overall question... | 40204123 | 2 | 75 | 2021-01-12 15:38:06 |
3 | Prop Logic | logic desc ... | overall quest... | 40204123 | 3 | 30 | 2021-01-13 22:13:13 |
4 | Pred Logic | pred desc 1 ... | predicase quest... | null | null | 0 | null |
l_id | l_title | l_q_desc | l_o_quest | s_no | s_l_id | s_points | s_ts |
---|---|---|---|---|---|---|---|
1 | Sets | The purpose of... | Suppose we have... | 40204123 | 1 | 80 | 2021-01-12 15:37:11 |
2 | Seqs | sequences desc... | overall question... | 40204123 | 2 | 75 | 2021-01-12 15:38:06 |
3 | Prop Logic | logic desc ... | overall quest... | 40204123 | 3 | 30 | 2021-01-13 22:13:13 |
1 | Sets | The purpose of... | Suppose we have... | 40213894 | 1 | 90 | 2021-01-14 21:52:00 |
2 | Seqs | sequences desc... | overall question... | 40213894 | 2 | 95 | 2021-01-17 22:42:50 |
4 | Pred Logic | pred desc 1 ... | predicase quest... | 40213894 | 4 | 100 | 2021-01-17 22:42:50 |
2 rows affected
id | level_title | quiz_desc | overall_quest | student_no | level_id | points | ts |
---|---|---|---|---|---|---|---|
1 | Sets | The purpose of... | Suppose we have... | 40204123 | 1 | 80 | 2021-01-12 15:37:11 |
2 | Seqs | sequences desc... | overall question... | 40204123 | 2 | 75 | 2021-01-12 15:38:06 |
3 | Prop Logic | logic desc ... | overall quest... | 40204123 | 3 | 30 | 2021-01-13 22:13:13 |
4 | Pred Logic | pred desc 1 ... | predicase quest... | 40204123 | 4 | null | null |
id | level_title | quiz_desc | overall_quest | student_no | level_id | points | ts |
---|---|---|---|---|---|---|---|
1 | Sets | The purpose of... | Suppose we have... | 40204123 | 1 | 80 | 2021-01-12 15:37:11 |
2 | Seqs | sequences desc... | overall question... | 40204123 | 2 | 75 | 2021-01-12 15:38:06 |
3 | Prop Logic | logic desc ... | overall quest... | 40204123 | 3 | 30 | 2021-01-13 22:13:13 |
4 | Pred Logic | pred desc 1 ... | predicase quest... | 40204123 | 4 | null | null |
1 | Sets | The purpose of... | Suppose we have... | 40213894 | 1 | 90 | 2021-01-14 21:52:00 |
2 | Seqs | sequences desc... | overall question... | 40213894 | 2 | 95 | 2021-01-17 22:42:50 |
3 | Prop Logic | logic desc ... | overall quest... | 40213894 | 3 | null | null |
4 | Pred Logic | pred desc 1 ... | predicase quest... | 40213894 | 4 | 100 | 2021-01-17 22:42:50 |
l_id | l_title | l_q_desc | l_o_quest | s_no | s_l_id | s_points | s_ts |
---|---|---|---|---|---|---|---|
1 | Sets | The purpose of... | Suppose we have... | 40204123 | 1 | 80 | 2021-01-12 15:37:11 |
2 | Seqs | sequences desc... | overall question... | 40204123 | 2 | 75 | 2021-01-12 15:38:06 |
3 | Prop Logic | logic desc ... | overall quest... | 40204123 | 3 | 30 | 2021-01-13 22:13:13 |
4 | Pred Logic | pred desc 1 ... | predicase quest... | 40204123 | 4 | null | null |
l_id | l_title | l_q_desc | l_o_quest | s_no | s_l_id | s_points | s_ts |
---|---|---|---|---|---|---|---|
1 | Sets | The purpose of... | Suppose we have... | 40204123 | 1 | 80 | 2021-01-12 15:37:11 |
2 | Seqs | sequences desc... | overall question... | 40204123 | 2 | 75 | 2021-01-12 15:38:06 |
3 | Prop Logic | logic desc ... | overall quest... | 40204123 | 3 | 30 | 2021-01-13 22:13:13 |
4 | Pred Logic | pred desc 1 ... | predicase quest... | 40204123 | 4 | null | null |
1 | Sets | The purpose of... | Suppose we have... | 40213894 | 1 | 90 | 2021-01-14 21:52:00 |
2 | Seqs | sequences desc... | overall question... | 40213894 | 2 | 95 | 2021-01-17 22:42:50 |
3 | Prop Logic | logic desc ... | overall quest... | 40213894 | 3 | null | null |
4 | Pred Logic | pred desc 1 ... | predicase quest... | 40213894 | 4 | 100 | 2021-01-17 22:42:50 |
2 rows affected
student_no | id |
---|---|
12345678 | 1 |
12345678 | 2 |
12345678 | 3 |
12345678 | 4 |
40204123 | 1 |
40204123 | 2 |
40204123 | 3 |
40204123 | 4 |
40213894 | 1 |
40213894 | 2 |
40213894 | 3 |
40213894 | 4 |
id | LT: | quiz_desc | overall_quest | student_no | Points: | ts |
---|---|---|---|---|---|---|
1 | Sets | The purpose of... | Suppose we have... | 40204123 | 80 | 2021-01-12 15:37:11 |
2 | Seqs | sequences desc... | overall question... | 40204123 | 75 | 2021-01-12 15:38:06 |
3 | Prop L | logic desc ... | overall quest... | 40204123 | 30 | 2021-01-13 22:13:13 |
4 | Pred L | pred desc 1 ... | predicase quest... | 40204123 | 0 | null |
1 | Sets | The purpose of... | Suppose we have... | 40213894 | 90 | 2021-01-14 21:52:00 |
2 | Seqs | sequences desc... | overall question... | 40213894 | 95 | 2021-01-17 22:42:50 |
3 | Prop L | logic desc ... | overall quest... | 40213894 | 0 | null |
4 | Pred L | pred desc 1 ... | predicase quest... | 40213894 | 100 | 2021-01-17 22:42:50 |
QUERY PLAN |
---|
Sort (cost=177.08..178.06 rows=392 width=986) (actual time=0.173..0.177 rows=8 loops=1) |
Sort Key: t2.student_no, t2.id |
Sort Method: quicksort Memory: 26kB |
Buffers: shared hit=4 |
-> Hash Join (cost=115.17..160.19 rows=392 width=986) (actual time=0.142..0.158 rows=8 loops=1) |
Hash Cond: (t2.id = lq2.id) |
Buffers: shared hit=4 |
-> Hash Right Join (cost=103.59..139.52 rows=1120 width=20) (actual time=0.098..0.109 rows=8 loops=1) |
Hash Cond: ((sp2.student_no = t2.student_no) AND (sp2.level_id = t2.id)) |
Buffers: shared hit=3 |
-> Seq Scan on student_points sp2 (cost=0.00..27.00 rows=1700 width=20) (actual time=0.007..0.008 rows=10 loops=1) |
Buffers: shared hit=1 |
-> Hash (cost=86.79..86.79 rows=1120 width=8) (actual time=0.070..0.071 rows=8 loops=1) |
Buckets: 2048 Batches: 1 Memory Usage: 17kB |
Buffers: shared hit=2 |
-> Subquery Scan on t2 (cost=64.39..86.79 rows=1120 width=8) (actual time=0.054..0.064 rows=8 loops=1) |
Buffers: shared hit=2 |
-> HashAggregate (cost=64.39..75.59 rows=1120 width=8) (actual time=0.053..0.061 rows=8 loops=1) |
Group Key: sp1.student_no, lq1.id |
Buffers: shared hit=2 |
-> Nested Loop (cost=10.88..58.44 rows=1190 width=8) (actual time=0.031..0.043 rows=24 loops=1) |
Buffers: shared hit=2 |
-> HashAggregate (cost=10.88..11.57 rows=70 width=4) (actual time=0.013..0.015 rows=4 loops=1) |
Group Key: lq1.id |
Buffers: shared hit=1 |
-> Seq Scan on level_quiz lq1 (cost=0.00..10.70 rows=70 width=4) (actual time=0.006..0.007 rows=4 loops=1) |
Buffers: shared hit=1 |
-> Materialize (cost=0.00..31.34 rows=17 width=4) (actual time=0.004..0.005 rows=6 loops=4) |
Buffers: shared hit=1 |
-> Seq Scan on student_points sp1 (cost=0.00..31.25 rows=17 width=4) (actual time=0.009..0.011 rows=6 loops=1) |
Filter: (student_no = ANY ('{40204123,40213894}'::integer[])) |
Rows Removed by Filter: 4 |
Buffers: shared hit=1 |
-> Hash (cost=10.70..10.70 rows=70 width=1056) (actual time=0.021..0.021 rows=4 loops=1) |
Buckets: 1024 Batches: 1 Memory Usage: 9kB |
Buffers: shared hit=1 |
-> Seq Scan on level_quiz lq2 (cost=0.00..10.70 rows=70 width=1056) (actual time=0.015..0.016 rows=4 loops=1) |
Buffers: shared hit=1 |
Planning Time: 0.309 ms |
Execution Time: 0.292 ms |