explain.depesz.com

PostgreSQL's explain analyze made readable

Result: JIx5

Settings
# exclusive inclusive rows x rows loops node
1. 0.005 855.623 ↓ 17.0 34 1

Append (cost=0.86..1,752.06 rows=2 width=36) (actual time=384.057..855.623 rows=34 loops=1)

2. 0.002 384.057 ↑ 1.0 1 1

Limit (cost=0.86..2.57 rows=1 width=36) (actual time=384.057..384.057 rows=1 loops=1)

3. 0.236 384.055 ↑ 65,624.0 1 1

Merge Join (cost=0.86..112,276.67 rows=65,624 width=36) (actual time=384.055..384.055 rows=1 loops=1)

  • Merge Cond: (ah.created_by = cu.id)
4. 371.085 371.085 ↑ 67,738.0 1 1

Index Scan using idx_ap_headers_created_by on ap_headers ah (cost=0.43..103,600.10 rows=67,738 width=8) (actual time=371.085..371.085 rows=1 loops=1)

  • Filter: ((NOT is_template) AND (cid = 15,443) AND (ap_header_type_id = 5) AND (gl_transaction_type_id = 2))
  • Rows Removed by Filter: 671,951
5. 12.734 12.734 ↑ 1.6 4,291 1

Index Scan using pk_company_users on company_users cu (cost=0.43..7,845.66 rows=7,032 width=8) (actual time=2.168..12.734 rows=4,291 loops=1)

  • Index Cond: (cid = 15,443)
  • Filter: ((company_employee_id IS NULL) AND (company_user_type_id = ANY ('{13,14,2}'::integer[])))
  • Rows Removed by Filter: 23
6. 5.909 471.561 ↓ 33.0 33 1

Unique (cost=1,749.45..1,749.46 rows=1 width=36) (actual time=462.271..471.561 rows=33 loops=1)

7. 17.826 465.652 ↓ 63,699.0 63,699 1

Sort (cost=1,749.45..1,749.45 rows=1 width=36) (actual time=462.269..465.652 rows=63,699 loops=1)

  • Sort Key: (array_to_string(ARRAY[ce.name_first, ce.name_last], ' '::text)), cu_1.id
  • Sort Method: quicksort Memory: 6,463kB
8. 32.045 447.826 ↓ 63,699.0 63,699 1

Nested Loop (cost=1,508.49..1,749.44 rows=1 width=36) (actual time=45.422..447.826 rows=63,699 loops=1)

9. 0.237 50.591 ↓ 555.0 555 1

Nested Loop (cost=313.86..405.59 rows=1 width=23) (actual time=21.856..50.591 rows=555 loops=1)

10. 0.401 19.719 ↓ 21.4 557 1

Bitmap Heap Scan on company_users cu_1 (cost=313.57..342.52 rows=26 width=12) (actual time=19.340..19.719 rows=557 loops=1)

  • Recheck Cond: ((cid = 15,443) AND (company_user_type_id = 2))
  • Heap Blocks: exact=125
11. 0.115 19.318 ↓ 0.0 0 1

BitmapAnd (cost=313.57..313.57 rows=26 width=0) (actual time=19.318..19.318 rows=0 loops=1)

12. 1.744 1.744 ↓ 1.1 7,765 1

Bitmap Index Scan on pk_company_users (cost=0.00..76.17 rows=7,165 width=0) (actual time=1.744..1.744 rows=7,765 loops=1)

  • Index Cond: (cid = 15,443)
13. 17.459 17.459 ↑ 1.2 19,132 1

Bitmap Index Scan on idx_company_users_company_user_type_id (cost=0.00..237.13 rows=22,467 width=0) (actual time=17.459..17.459 rows=19,132 loops=1)

  • Index Cond: (company_user_type_id = 2)
14. 30.635 30.635 ↑ 1.0 1 557

Index Scan using idx_company_employees_id on company_employees ce (cost=0.29..2.43 rows=1 width=23) (actual time=0.055..0.055 rows=1 loops=557)

  • Index Cond: (id = cu_1.company_employee_id)
  • Filter: (cid = 15,443)
15. 109.335 365.190 ↓ 1.4 115 555

Bitmap Heap Scan on ap_headers ah_1 (cost=1,194.63..1,343.01 rows=84 width=8) (actual time=0.483..0.658 rows=115 loops=555)

  • Recheck Cond: ((created_by = cu_1.id) AND (cid = 15,443))
  • Filter: ((ap_header_type_id = 5) AND (gl_transaction_type_id = 2))
  • Rows Removed by Filter: 79
  • Heap Blocks: exact=58,219
16. 2.925 255.855 ↓ 0.0 0 555

BitmapAnd (cost=1,194.63..1,194.63 rows=137 width=0) (actual time=0.461..0.461 rows=0 loops=555)

17. 12.210 12.210 ↑ 11.3 194 555

Bitmap Index Scan on idx_ap_headers_created_by (cost=0.00..23.33 rows=2,185 width=0) (actual time=0.022..0.022 rows=194 loops=555)

  • Index Cond: (created_by = cu_1.id)
18. 240.720 240.720 ↑ 1.0 108,989 34

Bitmap Index Scan on pk_ap_headers (cost=0.00..1,154.09 rows=109,675 width=0) (actual time=7.080..7.080 rows=108,989 loops=34)

  • Index Cond: (cid = 15,443)
Planning time : 63.584 ms
Execution time : 855.716 ms