By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0.
6 rows affected
| ag_id | name | cost |
|---|---|---|
| 1 | 333 | 22.00 |
| 1 | 333 | 33.00 |
| 1 | 333 | 7.00 |
| 2 | 555 | 18.00 |
| 2 | 555 | 2.00 |
| 3 | 777 | 4.00 |
| agreement_id | ag |
|---|---|
| 1 | (1,333,22.00) |
| 1 | (1,333,33.00) |
| 1 | (1,333,7.00) |
| 2 | (2,555,18.00) |
| 2 | (2,555,2.00) |
| 3 | (3,777,4.00) |
| QUERY PLAN |
|---|
| Subquery Scan on t (cost=0.15..91.50 rows=5 width=112) (actual time=0.060..0.095 rows=3 loops=1) |
| Output: t.agreement_id, t.ag, t.total |
| Filter: ((t.ag).ag_id = 1) |
| Rows Removed by Filter: 3 |
| Buffers: shared hit=2 |
| -> WindowAgg (cost=0.15..78.75 rows=1020 width=112) (actual time=0.056..0.089 rows=6 loops=1) |
| Output: t_1.ag_id, t_1.*, sum(t_1.cost) OVER (?) |
| Buffers: shared hit=2 |
| -> Index Scan using ag_idx on public.agreement t_1 (cost=0.15..63.45 rows=1020 width=96) (actual time=0.017..0.026 rows=6 loops=1) |
| Output: t_1.ag_id, t_1.*, t_1.cost |
| Buffers: shared hit=2 |
| Planning: |
| Buffers: shared hit=8 read=6 |
| Planning Time: 0.771 ms |
| Execution Time: 0.190 ms |
| QUERY PLAN |
|---|
| WindowAgg (cost=4.19..12.74 rows=5 width=112) (actual time=0.040..0.042 rows=3 loops=1) |
| Output: t.ag_id, t.*, sum(t.cost) OVER (?) |
| Buffers: shared hit=2 |
| -> Bitmap Heap Scan on public.agreement t (cost=4.19..12.66 rows=5 width=96) (actual time=0.017..0.020 rows=3 loops=1) |
| Output: t.ag_id, t.*, t.cost |
| Recheck Cond: (t.ag_id = 1) |
| Heap Blocks: exact=1 |
| Buffers: shared hit=2 |
| -> Bitmap Index Scan on ag_idx (cost=0.00..4.19 rows=5 width=0) (actual time=0.008..0.008 rows=3 loops=1) |
| Index Cond: (t.ag_id = 1) |
| Buffers: shared hit=1 |
| Planning Time: 0.132 ms |
| Execution Time: 0.201 ms |
| QUERY PLAN |
|---|
| Subquery Scan on t (cost=0.15..91.50 rows=5 width=112) (actual time=0.024..0.035 rows=3 loops=1) |
| Output: t.agreement_id, t.ag, t.total |
| Filter: (t.agreement_id = 1) |
| Rows Removed by Filter: 3 |
| Buffers: shared hit=2 |
| -> WindowAgg (cost=0.15..78.75 rows=1020 width=116) (actual time=0.023..0.032 rows=6 loops=1) |
| Output: t_1.ag_id, t_1.*, sum(t_1.cost) OVER (?), t_1.ag_id |
| Buffers: shared hit=2 |
| -> Index Scan using ag_idx on public.agreement t_1 (cost=0.15..63.45 rows=1020 width=96) (actual time=0.011..0.015 rows=6 loops=1) |
| Output: t_1.ag_id, t_1.*, t_1.cost |
| Buffers: shared hit=2 |
| Planning Time: 0.120 ms |
| Execution Time: 0.062 ms |
| QUERY PLAN |
|---|
| Subquery Scan on t (cost=0.15..91.50 rows=5 width=112) (actual time=0.024..0.035 rows=3 loops=1) |
| Output: t.agreement_id, t.ag, t.total |
| Filter: ((t.ag).ag_id = 1) |
| Rows Removed by Filter: 3 |
| Buffers: shared hit=2 |
| -> WindowAgg (cost=0.15..78.75 rows=1020 width=116) (actual time=0.022..0.031 rows=6 loops=1) |
| Output: t_1.ag_id, t_1.*, sum(t_1.cost) OVER (?), t_1.ag_id |
| Buffers: shared hit=2 |
| -> Index Scan using ag_idx on public.agreement t_1 (cost=0.15..63.45 rows=1020 width=96) (actual time=0.010..0.015 rows=6 loops=1) |
| Output: t_1.ag_id, t_1.*, t_1.cost |
| Buffers: shared hit=2 |
| Planning Time: 0.118 ms |
| Execution Time: 0.062 ms |