- WITH ranked_readouts AS (
- SELECT
- id,
- meter_id,
- timestamp,
- value,
- ignored,
- RANK() OVER (
- PARTITION BY meter_id
- ORDER BY
- timestamp DESC
- ) AS rank
- FROM
- metrius_readout
- WHERE
- meter_id IN (
- 444404,
- 444405,
- 444406,
- 444407,
- 444408,
- 227649,
- 227676,
- 227679,
- 227680,
- 227690,
- 227691,
- 227675,
- 227712,
- 227713,
- 227723,
- 227724,
- 234810,
- 234811,
- 2024710,
- 444394,
- 444395,
- 1791267,
- 1791268,
- 1791273,
- 1791269,
- 1791274,
- 1791270,
- 1791271,
- 1791272,
- 227664,
- 227665,
- 227650,
- 227683,
- 227684,
- 227701,
- 227702,
- 227651,
- 227652,
- 227653,
- 227654,
- 234809,
- 234812,
- 2024711,
- 2024712,
- 2024713,
- 2024714,
- 2024715
- )
- AND timestamp < '2022-07-19 00:00:00'
- AND ignored = 'f'
- )
- SELECT
- id,
- meter_id,
- timestamp,
- value,
- ignored
- FROM
- ranked_readouts
- WHERE
- rank = 1;
-
-
-
-
-
-
-
-
-
-
-
- Subquery Scan on ranked_readouts (cost=28529507.44..53157657.71 rows=840744 width=33) (actual time=71912.721..72328.174 rows=36 loops=1)
- Filter: (ranked_readouts.rank = 1)
- Rows Removed by Filter: 832641
- -> WindowAgg (cost=28529507.44..51055798.77 rows=168148715 width=41) (actual time=71912.719..72301.004 rows=832677 loops=1)
- -> Gather Merge (cost=28529507.44..48113196.26 rows=168148715 width=33) (actual time=71912.697..72015.758 rows=832677 loops=1)
- Workers Planned: 2
- Workers Launched: 0
- -> Sort (cost=28528507.42..28703662.33 rows=70061965 width=33) (actual time=71912.522..71964.651 rows=832677 loops=1)
- Sort Key: metrius_readout.meter_id, metrius_readout."timestamp" DESC
- Sort Method: quicksort Memory: 89629kB
- -> Parallel Seq Scan on metrius_readout (cost=0.12..17482927.88 rows=70061965 width=33) (actual time=68.466..71579.524 rows=832677 loops=1)
- Filter: ((NOT ignored) AND ("timestamp" < '2022-07-19 00:00:00+02'::timestamp with time zone) AND (meter_id = ANY ('{444404,444405,444406,444407,444408,227649,227676,227679,227680,227690,227691,227675,227712,227713,227723,227724,234810,234811,2024710,444394,444395,1791267,1791268,1791273,1791269,1791274,1791270,1791271,1791272,227664,227665,227650,227683,227684,227701,227702,227651,227652,227653,227654,234809,234812,2024711,2024712,2024713,2024714,2024715}'::bigint[])))
- Rows Removed by Filter: 1061018541
- Planning Time: 0.234 ms
- JIT:
- Functions: 10
- Options: Inlining true, Optimization true, Expressions true, Deforming true
- Timing: Generation 0.832 ms, Inlining 3.378 ms, Optimization 31.716 ms, Emission 23.972 ms, Total 59.897 ms
- Execution Time: 72332.692 ms
- (19 rows)