explain.depesz.com

PostgreSQL's explain analyze made readable

Result: OoC2

Settings
# exclusive inclusive rows x rows loops node
1. 0.000 0.000 ↓ 0.0

Group (cost=12,652,382.16..12,652,386.29 rows=50 width=1,658) (actual rows= loops=)

  • 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.000 0.000 ↓ 0.0

Sort (cost=12,652,382.16..12,652,382.29 rows=50 width=1,610) (actual rows= loops=)

  • 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))
3. 0.000 0.000 ↓ 0.0

Nested Loop (cost=253,047.30..12,652,380.75 rows=50 width=1,610) (actual rows= loops=)

4. 0.000 0.000 ↓ 0.0

Nested Loop (cost=166,976.07..8,348,817.00 rows=50 width=1,601) (actual rows= loops=)

5. 0.000 0.000 ↓ 0.0

Nested Loop (cost=79,613.23..3,980,673.50 rows=50 width=1,585) (actual rows= loops=)

6. 0.000 0.000 ↓ 0.0

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

7. 0.000 0.000 ↓ 0.0

Aggregate (cost=79,613.23..79,613.24 rows=1 width=2) (actual rows= loops=)

8. 0.000 0.000 ↓ 0.0

Seq Scan on polls_users pu (cost=0.00..77,030.02 rows=1,033,281 width=2) (actual rows= loops=)

  • Filter: ((poll_id)::text = (p._id)::text)
9. 0.000 0.000 ↓ 0.0

Aggregate (cost=87,362.83..87,362.85 rows=1 width=24) (actual rows= loops=)

10. 0.000 0.000 ↓ 0.0

Seq Scan on polls_users pu_1 (cost=0.00..77,030.02 rows=1,033,281 width=2) (actual rows= loops=)

  • Filter: ((poll_id)::text = (p._id)::text)
11. 0.000 0.000 ↓ 0.0

Aggregate (cost=86,071.23..86,071.24 rows=1 width=8) (actual rows= loops=)

12. 0.000 0.000 ↓ 0.0

Seq Scan on polls_users pu_2 (cost=0.00..84,779.63 rows=516,640 width=2) (actual rows= loops=)

  • Filter: (((p._id)::text = (poll_id)::text) AND (preferred_option = p.correct_option))