explain.depesz.com

PostgreSQL's explain analyze made readable

Result: bZQm : Optimization for: plan #Pg7q

Settings

Optimization path:

# exclusive inclusive rows x rows loops node
1. 0.003 13,360.561 ↑ 1.0 5 1

Limit (cost=613.34..616.02 rows=5 width=166) (actual time=13,360.548..13,360.561 rows=5 loops=1)

2. 565.879 13,360.558 ↑ 62,324.0 5 1

WindowAgg (cost=613.34..167,197.66 rows=311,620 width=166) (actual time=13,360.547..13,360.558 rows=5 loops=1)

3. 770.449 12,794.679 ↓ 2.0 635,917 1

Nested Loop Left Join (cost=613.34..166,106.99 rows=311,620 width=158) (actual time=0.108..12,794.679 rows=635,917 loops=1)

4. 547.390 6,936.894 ↓ 2.0 635,917 1

Nested Loop Left Join (cost=613.26..97,912.59 rows=311,620 width=162) (actual time=0.094..6,936.894 rows=635,917 loops=1)

5. 537.324 2,574.002 ↓ 2.0 635,917 1

Nested Loop (cost=613.20..47,821.83 rows=311,620 width=167) (actual time=0.081..2,574.002 rows=635,917 loops=1)

6. 0.012 0.336 ↑ 34.4 7 1

Nested Loop (cost=613.09..1,578.50 rows=241 width=95) (actual time=0.049..0.336 rows=7 loops=1)

7. 0.205 0.205 ↑ 34.4 7 1

CTE Scan on subaccounts (cost=613.01..614.45 rows=241 width=108) (actual time=0.036..0.205 rows=7 loops=1)

8.          

CTE subaccounts

9. 0.019 0.197 ↑ 34.4 7 1

Recursive Union (cost=0.08..613.01 rows=241 width=38) (actual time=0.035..0.197 rows=7 loops=1)

10. 0.034 0.034 ↑ 1.0 1 1

Index Scan using account_sfid_key on account p (cost=0.08..4.09 rows=1 width=38) (actual time=0.032..0.034 rows=1 loops=1)

  • Index Cond: ((sfid)::text = ANY ('{0016000000mp9FwAAI}'::text[]))
11. 0.015 0.144 ↑ 12.0 2 3

Nested Loop (cost=0.08..60.75 rows=24 width=38) (actual time=0.033..0.048 rows=2 loops=3)

12. 0.003 0.003 ↑ 5.0 2 3

WorkTable Scan on subaccounts s (cost=0.00..0.06 rows=10 width=54) (actual time=0.001..0.001 rows=2 loops=3)

13. 0.126 0.126 ↑ 2.0 1 7

Index Scan using account_parentid_idx on account c (cost=0.08..6.06 rows=2 width=38) (actual time=0.017..0.018 rows=1 loops=7)

  • Index Cond: ((parentid)::text = (s.sfid)::text)
14. 0.119 0.119 ↑ 1.0 1 7

Index Scan using account_sfid_key on account acct (cost=0.08..4.00 rows=1 width=41) (actual time=0.017..0.017 rows=1 loops=7)

  • Index Cond: ((sfid)::text = (subaccounts.sfid)::text)
15. 2,036.342 2,036.342 ↓ 70.3 90,845 7

Index Scan using cpq__c_account__c_idx on cpq__c cpq (cost=0.11..188.00 rows=1,293 width=164) (actual time=0.026..290.906 rows=90,845 loops=7)

  • Index Cond: ((account__c)::text = (acct.sfid)::text)
16. 3,815.502 3,815.502 ↑ 1.0 1 635,917

Index Scan using user_sfid_key on "user" usr (cost=0.06..0.16 rows=1 width=33) (actual time=0.006..0.006 rows=1 loops=635,917)

  • Index Cond: ((sfid)::text = (cpq.createdbyid)::text)
17. 5,087.336 5,087.336 ↑ 1.0 1 635,917

Index Scan using contact_sfid_key on contact con (cost=0.08..0.22 rows=1 width=34) (actual time=0.008..0.008 rows=1 loops=635,917)

  • Index Cond: ((sfid)::text = (cpq.created_by_contact__c)::text)
Planning time : 2.484 ms