Snippet content copied to clipboard.
Are you sure to delete this snippet? No, don't delete

Comparison with previous snippet

  1. --- Previous Snippet
  2. +++ Current Snippet
  3. @@ -1 +1,29 @@
  4. +-- without seq_scan enabled
  5. +Subquery Scan on ranked_readouts (cost=29951050.70..54579200.96 rows=840744 width=33) (actual time=689.271..1075.429 rows=36 loops=1)
  6. + Filter: (ranked_readouts.rank = 1)
  7. + Rows Removed by Filter: 832641
  8. + -> WindowAgg (cost=29951050.70..52477342.03 rows=168148715 width=41) (actual time=689.270..1050.556 rows=832677 loops=1)
  9. + -> Gather Merge (cost=29951050.70..49534739.51 rows=168148715 width=33) (actual time=689.254..789.413 rows=832677 loops=1)
  10. + Workers Planned: 2
  11. + Workers Launched: 0
  12. + -> Sort (cost=29950050.67..30125205.59 rows=70061965 width=33) (actual time=688.973..742.501 rows=832677 loops=1)
  13. + Sort Key: metrius_readout.meter_id, metrius_readout."timestamp" DESC
  14. + Sort Method: quicksort Memory: 89629kB
  15. + -> Parallel Bitmap Heap Scan on metrius_readout (cost=2696913.34..18904471.14 rows=70061965 width=33) (actual time=145.713..376.225 rows=832677 loops=1)
  16. + 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[]))
  17. + Filter: ((NOT ignored) AND ("timestamp" < '2022-07-19 00:00:00+02'::timestamp with time zone))
  18. + Rows Removed by Filter: 1502214
  19. + Heap Blocks: exact=86065
  20. + -> Bitmap Index Scan on metrius_readout_meter_id (cost=0.00..2654876.04 rows=249543049 width=0) (actual time=71.511..71.512 rows=2334891 loops=1)
  21. + 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[]))
  22. + Planning Time: 0.271 ms
  23. + JIT:
  24. + Functions: 12
  25. + Options: Inlining true, Optimization true, Expressions true, Deforming true
  26. + Timing: Generation 1.200 ms, Inlining 3.082 ms, Optimization 32.731 ms, Emission 24.207 ms, Total 61.219 ms
  27. + Execution Time: 1079.415 ms
  28. +
  29. +
  30. +---------------
  31. +
  32. WITH ranked_readouts AS (
  33. @@ -108 +136,4 @@
  34. (19 rows)
  35. +
  36. +
  37. +
  1. -- without seq_scan enabled
  2. Subquery Scan on ranked_readouts (cost=29951050.70..54579200.96 rows=840744 width=33) (actual time=689.271..1075.429 rows=36 loops=1)
  3. Filter: (ranked_readouts.rank = 1)
  4. Rows Removed by Filter: 832641
  5. -> WindowAgg (cost=29951050.70..52477342.03 rows=168148715 width=41) (actual time=689.270..1050.556 rows=832677 loops=1)
  6. -> Gather Merge (cost=29951050.70..49534739.51 rows=168148715 width=33) (actual time=689.254..789.413 rows=832677 loops=1)
  7. Workers Planned: 2
  8. Workers Launched: 0
  9. -> Sort (cost=29950050.67..30125205.59 rows=70061965 width=33) (actual time=688.973..742.501 rows=832677 loops=1)
  10. Sort Key: metrius_readout.meter_id, metrius_readout."timestamp" DESC
  11. Sort Method: quicksort Memory: 89629kB
  12. -> Parallel Bitmap Heap Scan on metrius_readout (cost=2696913.34..18904471.14 rows=70061965 width=33) (actual time=145.713..376.225 rows=832677 loops=1)
  13. 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[]))
  14. Filter: ((NOT ignored) AND ("timestamp" < '2022-07-19 00:00:00+02'::timestamp with time zone))
  15. Rows Removed by Filter: 1502214
  16. Heap Blocks: exact=86065
  17. -> Bitmap Index Scan on metrius_readout_meter_id (cost=0.00..2654876.04 rows=249543049 width=0) (actual time=71.511..71.512 rows=2334891 loops=1)
  18. 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[]))
  19. Planning Time: 0.271 ms
  20. JIT:
  21. Functions: 12
  22. Options: Inlining true, Optimization true, Expressions true, Deforming true
  23. Timing: Generation 1.200 ms, Inlining 3.082 ms, Optimization 32.731 ms, Emission 24.207 ms, Total 61.219 ms
  24. Execution Time: 1079.415 ms
  25. ---------------
  26. WITH ranked_readouts AS (
  27. SELECT
  28. id,
  29. meter_id,
  30. timestamp,
  31. value,
  32. ignored,
  33. RANK() OVER (
  34. PARTITION BY meter_id
  35. ORDER BY
  36. timestamp DESC
  37. ) AS rank
  38. FROM
  39. metrius_readout
  40. WHERE
  41. meter_id IN (
  42. 444404,
  43. 444405,
  44. 444406,
  45. 444407,
  46. 444408,
  47. 227649,
  48. 227676,
  49. 227679,
  50. 227680,
  51. 227690,
  52. 227691,
  53. 227675,
  54. 227712,
  55. 227713,
  56. 227723,
  57. 227724,
  58. 234810,
  59. 234811,
  60. 2024710,
  61. 444394,
  62. 444395,
  63. 1791267,
  64. 1791268,
  65. 1791273,
  66. 1791269,
  67. 1791274,
  68. 1791270,
  69. 1791271,
  70. 1791272,
  71. 227664,
  72. 227665,
  73. 227650,
  74. 227683,
  75. 227684,
  76. 227701,
  77. 227702,
  78. 227651,
  79. 227652,
  80. 227653,
  81. 227654,
  82. 234809,
  83. 234812,
  84. 2024711,
  85. 2024712,
  86. 2024713,
  87. 2024714,
  88. 2024715
  89. )
  90. AND timestamp < '2022-07-19 00:00:00'
  91. AND ignored = 'f'
  92. )
  93. SELECT
  94. id,
  95. meter_id,
  96. timestamp,
  97. value,
  98. ignored
  99. FROM
  100. ranked_readouts
  101. WHERE
  102. rank = 1;
  103. Subquery Scan on ranked_readouts (cost=28529507.44..53157657.71 rows=840744 width=33) (actual time=71912.721..72328.174 rows=36 loops=1)
  104. Filter: (ranked_readouts.rank = 1)
  105. Rows Removed by Filter: 832641
  106. -> WindowAgg (cost=28529507.44..51055798.77 rows=168148715 width=41) (actual time=71912.719..72301.004 rows=832677 loops=1)
  107. -> Gather Merge (cost=28529507.44..48113196.26 rows=168148715 width=33) (actual time=71912.697..72015.758 rows=832677 loops=1)
  108. Workers Planned: 2
  109. Workers Launched: 0
  110. -> Sort (cost=28528507.42..28703662.33 rows=70061965 width=33) (actual time=71912.522..71964.651 rows=832677 loops=1)
  111. Sort Key: metrius_readout.meter_id, metrius_readout."timestamp" DESC
  112. Sort Method: quicksort Memory: 89629kB
  113. -> 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)
  114. 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[])))
  115. Rows Removed by Filter: 1061018541
  116. Planning Time: 0.234 ms
  117. JIT:
  118. Functions: 10
  119. Options: Inlining true, Optimization true, Expressions true, Deforming true
  120. Timing: Generation 0.832 ms, Inlining 3.378 ms, Optimization 31.716 ms, Emission 23.972 ms, Total 59.897 ms
  121. Execution Time: 72332.692 ms
  122. (19 rows)

Edit this Snippet