By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0.
3 rows affected
6 rows affected
| station_id | reading_id | temp | air_pressure |
|---|---|---|---|
| 147 | 100 | 10 | 800 |
| 148 | 103 | 40 | 950 |
| station_id | reading_id | temp | air_pressure |
|---|---|---|---|
| 147 | 100 | 10 | 800 |
| 148 | 103 | 40 | 950 |
| QUERY PLAN |
|---|
| Subquery Scan on r (cost=0.13..12.40 rows=1 width=16) (actual time=0.093..0.106 rows=2 loops=1) |
| Filter: (r.rnk = 2) |
| Rows Removed by Filter: 4 |
| -> WindowAgg (cost=0.13..12.33 rows=6 width=56) (actual time=0.085..0.100 rows=6 loops=1) |
| -> Index Scan using readings_station_id_reading_id_idx on readings r_1 (cost=0.13..12.22 rows=6 width=48) (actual time=0.060..0.067 rows=6 loops=1) |
| Planning Time: 0.210 ms |
| Execution Time: 0.179 ms |
| QUERY PLAN |
|---|
| Sort (cost=32.76..32.77 rows=3 width=16) (actual time=0.116..0.118 rows=2 loops=1) |
| Sort Key: r.station_id |
| Sort Method: quicksort Memory: 25kB |
| -> Nested Loop (cost=4.28..32.74 rows=3 width=16) (actual time=0.094..0.106 rows=2 loops=1) |
| -> Index Only Scan using stations_pkey on stations s (cost=0.13..8.18 rows=3 width=4) (actual time=0.039..0.041 rows=3 loops=1) |
| Heap Fetches: 0 |
| -> Limit (cost=4.15..8.17 rows=1 width=16) (actual time=0.019..0.019 rows=1 loops=3) |
| -> Index Scan using readings_station_id_reading_id_idx on readings r (cost=0.13..8.17 rows=2 width=16) (actual time=0.017..0.018 rows=2 loops=3) |
| Index Cond: (station_id = s.id) |
| Planning Time: 0.274 ms |
| Execution Time: 0.173 ms |