explain.depesz.com

PostgreSQL's explain analyze made readable

Result: fQtg

Settings
# exclusive inclusive rows x rows loops node
1. 0.019 727.761 ↑ 16.7 3 1

Group (cost=5,751,398.66..5,751,402.79 rows=50 width=1,658) (actual time=727.746..727.761 rows=3 loops=1)

  • Group Key: p._id, (count(pu_1.preferred_option)), (((count(pu_1.preferred_option))::double precision * p.consensus_rule)), (mode() WITHIN GROUP (ORDER BY pu.preferred_option)), (count(pu_1.preferred_option) FILTER (WHERE (pu_1.preferred_option = (mode() WITHIN GROUP (ORDER BY pu.preferred_option))))), (CASE WHEN ((p.min_consensus <= (count(pu_1.preferred_option) FILTER (WHERE (pu_1.preferred_option = (mode() WITHIN GROUP (ORDER BY pu.preferred_option)))))) AND ((((count(pu_1.preferred_option))::double precision * p.consensus_rule)) <= ((count(pu_1.preferred_option) FILTER (WHERE (pu_1.preferred_option = (mode() WITHIN GROUP (ORDER BY pu.preferred_option))))))::double precision)) THEN true WHEN ((p.min_consensus > (count(pu_1.preferred_option) FILTER (WHERE (pu_1.preferred_option = (mode() WITHIN GROUP (ORDER BY pu.preferred_option)))))) OR ((((count(pu_1.preferred_option))::double precision * p.consensus_rule)) > ((count(pu_1.preferred_option) FILTER (WHERE (pu_1.preferred_option = (mode() WITHIN GROUP (ORDER BY pu.preferred_option))))))::double precision)) THEN false ELSE NULL::boolean END), (count(pu_2.preferred_option))
2. 0.023 727.742 ↑ 16.7 3 1

Sort (cost=5,751,398.66..5,751,398.79 rows=50 width=1,610) (actual time=727.740..727.742 rows=3 loops=1)

  • Sort Key: p._id, (count(pu_1.preferred_option)), (((count(pu_1.preferred_option))::double precision * p.consensus_rule)), (mode() WITHIN GROUP (ORDER BY pu.preferred_option)), (count(pu_1.preferred_option) FILTER (WHERE (pu_1.preferred_option = (mode() WITHIN GROUP (ORDER BY pu.preferred_option))))), (CASE WHEN ((p.min_consensus <= (count(pu_1.preferred_option) FILTER (WHERE (pu_1.preferred_option = (mode() WITHIN GROUP (ORDER BY pu.preferred_option)))))) AND ((((count(pu_1.preferred_option))::double precision * p.consensus_rule)) <= ((count(pu_1.preferred_option) FILTER (WHERE (pu_1.preferred_option = (mode() WITHIN GROUP (ORDER BY pu.preferred_option))))))::double precision)) THEN true WHEN ((p.min_consensus > (count(pu_1.preferred_option) FILTER (WHERE (pu_1.preferred_option = (mode() WITHIN GROUP (ORDER BY pu.preferred_option)))))) OR ((((count(pu_1.preferred_option))::double precision * p.consensus_rule)) > ((count(pu_1.preferred_option) FILTER (WHERE (pu_1.preferred_option = (mode() WITHIN GROUP (ORDER BY pu.preferred_option))))))::double precision)) THEN false ELSE NULL::boolean END), (count(pu_2.preferred_option))
  • Sort Method: quicksort Memory: 25kB
3. 0.018 727.719 ↑ 16.7 3 1

Nested Loop (cost=115,027.62..5,751,397.25 rows=50 width=1,610) (actual time=245.062..727.719 rows=3 loops=1)

4. 0.019 487.872 ↑ 16.7 3 1

Nested Loop (cost=76,690.72..3,834,549.50 rows=50 width=1,601) (actual time=164.836..487.872 rows=3 loops=1)

5. 0.018 254.201 ↑ 16.7 3 1

Nested Loop (cost=38,332.69..1,916,646.38 rows=50 width=1,585) (actual time=87.066..254.201 rows=3 loops=1)

6. 0.008 0.008 ↑ 16.7 3 1

Seq Scan on polls p (cost=0.00..10.50 rows=50 width=1,583) (actual time=0.004..0.008 rows=3 loops=1)

7. 1.005 254.175 ↑ 1.0 1 3

Aggregate (cost=38,332.69..38,332.70 rows=1 width=2) (actual time=84.725..84.725 rows=1 loops=3)

8. 253.170 253.170 ↑ 5.1 667 3

Seq Scan on polls_users pu (cost=0.00..38,324.24 rows=3,379 width=2) (actual time=84.031..84.390 rows=667 loops=3)

  • Filter: ((poll_id)::text = (p._id)::text)
  • Rows Removed by Filter: 1333
9. 1.011 233.652 ↑ 1.0 1 3

Aggregate (cost=38,358.03..38,358.04 rows=1 width=24) (actual time=77.883..77.884 rows=1 loops=3)

10. 232.641 232.641 ↑ 5.1 667 3

Seq Scan on polls_users pu_1 (cost=0.00..38,324.24 rows=3,379 width=2) (actual time=77.213..77.547 rows=667 loops=3)

  • Filter: ((poll_id)::text = (p._id)::text)
  • Rows Removed by Filter: 1333
11. 0.441 239.829 ↑ 1.0 1 3

Aggregate (cost=38,336.91..38,336.92 rows=1 width=8) (actual time=79.942..79.943 rows=1 loops=3)

12. 239.388 239.388 ↑ 5.1 331 3

Seq Scan on polls_users pu_2 (cost=0.00..38,332.68 rows=1,690 width=2) (actual time=79.561..79.796 rows=331 loops=3)

  • Filter: (((p._id)::text = (poll_id)::text) AND (preferred_option = p.correct_option))
  • Rows Removed by Filter: 1669