explain.depesz.com

PostgreSQL's explain analyze made readable

Result: r3Ik : Add lateral JOIN

Settings

Optimization path:

# exclusive inclusive rows x rows loops node
1. 0.431 681.054 ↓ 7.9 262 1

GroupAggregate (cost=1,019,349.58..1,019,350.32 rows=33 width=48) (actual time=680.594..681.054 rows=262 loops=1)

  • Group Key: executions.user_uuid, executions.store_uuid
2. 0.381 680.623 ↓ 7.9 262 1

Sort (cost=1,019,349.58..1,019,349.66 rows=33 width=36) (actual time=680.563..680.623 rows=262 loops=1)

  • Sort Key: executions.user_uuid, executions.store_uuid
  • Sort Method: quicksort Memory: 45kB
3. 0.149 680.242 ↓ 7.9 262 1

Nested Loop (cost=0.71..1,019,348.75 rows=33 width=36) (actual time=3.980..680.242 rows=262 loops=1)

4. 0.023 0.023 ↑ 1.0 1 1

Index Scan using index_activities_on_uuid on activities (cost=0.29..8.31 rows=1 width=32) (actual time=0.022..0.023 rows=1 loops=1)

  • Index Cond: (uuid = '9c71adfd-5b88-4186-a4e5-96d16ecddaf0'::uuid)
  • Filter: (active AND ((state)::text = ANY ('{published,unpublished}'::text[])) AND (company_uuid = '38836b91-5616-4698-ac9d-4a147c255002'::uuid) AND (enum_activity_type = 0))
5. 0.434 680.070 ↓ 7.9 262 1

Nested Loop (cost=0.42..1,019,340.10 rows=33 width=68) (actual time=3.956..680.070 rows=262 loops=1)

6. 0.133 678.326 ↓ 3.5 262 1

Append (cost=0.00..1,018,715.36 rows=74 width=68) (actual time=3.939..678.326 rows=262 loops=1)

7. 0.000 0.022 ↓ 0.0 0 1

Seq Scan on executions (cost=0.00..0.00 rows=1 width=68) (actual time=0.022..0.022 rows=0 loops=1)

  • Filter: ((started_at >= '2020-06-22 05:00:00'::timestamp without time zone) AND (started_at < '2020-06-23 04:59:59'::timestamp without time zone) AND (activity_uuid = '9c71adfd-5b88-4186-a4e5-96d16ecddaf0'::uuid) AND (company_uuid = '38836b91-5616-4698-ac9d-4a147c255002'::uuid) AND (activity_type_id = 1) AND (SubPlan 1))
8.          

SubPlan (for Seq Scan)

9. 677.376 677.376 ↑ 1.0 1 294

Index Only Scan using index_activity_assignations_on_company_and_user_and_store on activity_assignations (cost=0.56..6,927.99 rows=1 width=0) (actual time=2.304..2.304 rows=1 loops=294)

  • Index Cond: ((company_uuid = executions.company_uuid) AND (store_uuid = executions.store_uuid))
  • Heap Fetches: 262
10. 678.171 678.171 ↓ 3.6 262 1

Index Scan using executions_38836b91_202006_company_date_activity_store_user on executions_38836b91_202006 (cost=0.28..1,018,715.36 rows=73 width=68) (actual time=3.917..678.171 rows=262 loops=1)

  • Index Cond: ((company_uuid = '38836b91-5616-4698-ac9d-4a147c255002'::uuid) AND (started_at >= '2020-06-22 05:00:00'::timestamp without time zone) AND (started_at < '2020-06-23 04:59:59'::timestamp without time zone) AND (activity_type_id = 1) AND (activity_uuid = '9c71adfd-5b88-4186-a4e5-96d16ecddaf0'::uuid))
  • Filter: (SubPlan 1)
  • Rows Removed by Filter: 32
11. 1.310 1.310 ↑ 1.0 1 262

Index Scan using index_stores_on_uuid on stores (cost=0.42..8.44 rows=1 width=16) (actual time=0.005..0.005 rows=1 loops=262)

  • Index Cond: (uuid = executions.store_uuid)
  • Filter: active
Planning time : 399.236 ms
Execution time : 681.282 ms