- explain analyze 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=2927062.80..2957590.34 rows=4697 width=33) (actual time=480.563..789.980 rows=36 loops=1)
- Filter: (ranked_readouts.rank = 1)
- Rows Removed by Filter: 832641
- -> WindowAgg (cost=2927062.80..2945848.98 rows=939309 width=41) (actual time=480.562..767.270 rows=832677 loops=1)
- -> Sort (cost=2927062.80..2929411.07 rows=939309 width=33) (actual time=480.549..525.889 rows=832677 loops=1)
- Sort Key: metrius_readout.meter_id, metrius_readout."timestamp" DESC
- Sort Method: quicksort Memory: 89629kB
- -> Bitmap Heap Scan on metrius_readout (cost=24414.56..2833877.52 rows=939309 width=33) (actual time=86.977..195.763 rows=832677 loops=1)
- Recheck Cond: ((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[])) AND ("timestamp" < '2022-07-19 00:00:00+02'::timestamp with time zone))
- Filter: (NOT ignored)
- Rows Removed by Filter: 40
- Heap Blocks: exact=48446
- -> Bitmap Index Scan on metrius_readout_meter_id_timestamp_desc (cost=0.00..24179.62 rows=949276 width=0) (actual time=29.529..29.529 rows=832717 loops=1)
- Index Cond: ((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[])) AND ("timestamp" < '2022-07-19 00:00:00+02'::timestamp with time zone))
- Planning Time: 0.180 ms
- JIT:
- Functions: 12
- Options: Inlining true, Optimization true, Expressions true, Deforming true
- Timing: Generation 0.800 ms, Inlining 2.734 ms, Optimization 28.138 ms, Emission 20.926 ms, Total 52.599 ms
- Execution Time: 795.707 ms
- (20 rows)