explain.depesz.com

PostgreSQL's explain analyze made readable

Result: CiAy

Settings
# exclusive inclusive rows x rows loops node
1. 2,560.116 2,566.359 ↓ 7.9 134,161 1

Index Scan using index_sent_mails_on_created_at on sent_mails (cost=734.99..661,486.81 rows=17,049 width=3,161) (actual time=5.752..2,566.359 rows=134,161 loops=1)

  • Index Cond: ((created_at >= '2019-01-01 08:00:00'::timestamp without time zone) AND (created_at <= '2019-03-19 06:59:59'::timestamp without time zone))
  • Filter: ((((resource_type)::text = 'Contact'::text) AND ((contacts_permissions_cache && '{69061}'::integer[]) OR (contacts_company_permissions_cache && '{69060}'::integer[]))) OR (((resource_type)::text = 'UserAccount'::text) AND (user_accounts_company_id = 16782)) OR (((resource_type)::text = 'Borrower'::text) AND (urla_forms_permissions_cache && $3)))
  • Rows Removed by Filter: 1759560
2.          

Initplan (for Index Scan)

3. 0.073 6.243 ↑ 1.0 1 1

Aggregate (cost=734.54..734.55 rows=1 width=4) (actual time=6.243..6.243 rows=1 loops=1)

4.          

CTE roles

5. 0.164 6.097 ↑ 2.7 225 1

Recursive Union (cost=0.42..720.99 rows=602 width=4) (actual time=1.380..6.097 rows=225 loops=1)

6. 1.361 1.361 ↑ 1.0 2 1

Index Only Scan using idx_resource_membership_dual_uuid on resources_memberships (cost=0.42..3.45 rows=2 width=4) (actual time=1.359..1.361 rows=2 loops=1)

  • Index Cond: (resource_uuid = 69061)
  • Heap Fetches: 0
7. 0.042 4.572 ↓ 3.8 226 2

Nested Loop (cost=0.42..70.55 rows=60 width=4) (actual time=0.028..2.286 rows=226 loops=2)

8. 0.030 0.030 ↓ 5.6 112 2

WorkTable Scan on roles (cost=0.00..0.40 rows=20 width=4) (actual time=0.002..0.015 rows=112 loops=2)

9. 4.500 4.500 ↑ 1.5 2 225

Index Only Scan using idx_resource_membership_dual_uuid on resources_memberships resources_memberships_1 (cost=0.42..3.48 rows=3 width=8) (actual time=0.015..0.020 rows=2 loops=225)

  • Index Cond: (resource_uuid = roles.membership_uuid)
  • Heap Fetches: 22
10. 6.170 6.170 ↑ 2.7 225 1

CTE Scan on roles roles_1 (cost=0.00..12.04 rows=602 width=4) (actual time=1.384..6.170 rows=225 loops=1)

Planning time : 2.365 ms
Execution time : 2,572.820 ms