explain.depesz.com

PostgreSQL's explain analyze made readable

Result: tusK : query_original

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

Unique (cost=787,145.60..793,984.52 rows=29,769 width=492) (actual rows= loops=)

2. 0.000 0.000 ↓ 0.0

Finalize GroupAggregate (cost=787,145.60..793,910.10 rows=29,769 width=492) (actual rows= loops=)

  • Group Key: t.id, d.created_at, o.key_origin, oc.name, s.name, ts.name, (date_part('month'::text, t.created_at)), (date_part('year'::text, t.created_at)), ba.state, ba.city, ba.cep, p.name, p.email, p.phone_number, pc.code, invoices.status, (COALESCE((invoices.metadata ->> 'note_number'::text), (invoices.metadata ->> 'fiscal_note_number'::text))), (COALESCE((invoices.metadata ->> 'emission_date'::text), (invoices.metadata ->> 'cae_generation_date'::text))), invoices.fiscal_key, ds.name, d.carrier_name, d.tracking_code, (((ot.deliveries)::numeric / 100.00)), (((ot.discounts_payments)::numeric / 100.00)), (((ot.discounts_vouchers)::numeric / 100.00)), ((COALESCE((invoices.metadata ->> 'total'::text), (invoices.metadata ->> 'invoice_total'::text)))::double precision)
3. 0.000 0.000 ↓ 0.0

Gather Merge (cost=787,145.60..791,280.47 rows=24,808 width=492) (actual rows= loops=)

  • Workers Planned: 2
4. 0.000 0.000 ↓ 0.0

Partial GroupAggregate (cost=786,145.58..787,416.99 rows=12,404 width=492) (actual rows= loops=)

  • Group Key: t.id, d.created_at, o.key_origin, oc.name, s.name, ts.name, (date_part('month'::text, t.created_at)), (date_part('year'::text, t.created_at)), ba.state, ba.city, ba.cep, p.name, p.email, p.phone_number, pc.code, invoices.status, (COALESCE((invoices.metadata ->> 'note_number'::text), (invoices.metadata ->> 'fiscal_note_number'::text))), (COALESCE((invoices.metadata ->> 'emission_date'::text), (invoices.metadata ->> 'cae_generation_date'::text))), invoices.fiscal_key, ds.name, d.carrier_name, d.tracking_code, (((ot.deliveries)::numeric / 100.00)), (((ot.discounts_payments)::numeric / 100.00)), (((ot.discounts_vouchers)::numeric / 100.00)), ((COALESCE((invoices.metadata ->> 'total'::text), (invoices.metadata ->> 'invoice_total'::text)))::double precision)
5. 0.000 0.000 ↓ 0.0

Sort (cost=786,145.58..786,176.59 rows=12,404 width=488) (actual rows= loops=)

  • Sort Key: t.id, d.created_at DESC, o.key_origin, oc.name, s.name, ts.name, (date_part('month'::text, t.created_at)), (date_part('year'::text, t.created_at)), ba.state, ba.city, ba.cep, p.name, p.email, p.phone_number, pc.code, invoices.status, (COALESCE((invoices.metadata ->> 'note_number'::text), (invoices.metadata ->> 'fiscal_note_number'::text))), (COALESCE((invoices.metadata ->> 'emission_date'::text), (invoices.metadata ->> 'cae_generation_date'::text))), invoices.fiscal_key, ds.name, d.carrier_name, d.tracking_code, (((ot.deliveries)::numeric / 100.00)), (((ot.discounts_payments)::numeric / 100.00)), (((ot.discounts_vouchers)::numeric / 100.00)), ((COALESCE((invoices.metadata ->> 'total'::text), (invoices.metadata ->> 'invoice_total'::text)))::double precision)
6. 0.000 0.000 ↓ 0.0

Hash Left Join (cost=456,258.43..782,586.20 rows=12,404 width=488) (actual rows= loops=)

  • Hash Cond: (d.delivery_status_id = ds.id)
7. 0.000 0.000 ↓ 0.0

Nested Loop Left Join (cost=456,257.18..782,291.76 rows=12,404 width=378) (actual rows= loops=)

8. 0.000 0.000 ↓ 0.0

Nested Loop Left Join (cost=456,256.75..677,185.63 rows=12,404 width=348) (actual rows= loops=)

9. 0.000 0.000 ↓ 0.0

Nested Loop (cost=456,256.32..617,408.85 rows=12,404 width=223) (actual rows= loops=)

10. 0.000 0.000 ↓ 0.0

Parallel Hash Left Join (cost=456,255.89..544,907.73 rows=12,404 width=215) (actual rows= loops=)

  • Hash Cond: (t.promo_code_id = pc.id)
11. 0.000 0.000 ↓ 0.0

Parallel Hash Join (cost=444,358.04..531,233.32 rows=12,404 width=208) (actual rows= loops=)

  • Hash Cond: (oi.transaction_id = t.id)
12. 0.000 0.000 ↓ 0.0

Parallel Seq Scan on order_items oi (cost=0.00..79,939.80 rows=1,835,680 width=20) (actual rows= loops=)

13. 0.000 0.000 ↓ 0.0

Parallel Hash (cost=444,136.71..444,136.71 rows=17,706 width=196) (actual rows= loops=)

14. 0.000 0.000 ↓ 0.0

Nested Loop (cost=4,084.75..444,136.71 rows=17,706 width=196) (actual rows= loops=)

15. 0.000 0.000 ↓ 0.0

Nested Loop (cost=4,084.32..352,224.89 rows=17,706 width=140) (actual rows= loops=)

16. 0.000 0.000 ↓ 0.0

Hash Join (cost=4,083.88..244,934.59 rows=17,706 width=114) (actual rows= loops=)

  • Hash Cond: (t.transaction_status_id = ts.id)
17. 0.000 0.000 ↓ 0.0

Hash Join (cost=4,078.20..244,879.80 rows=17,706 width=96) (actual rows= loops=)

  • Hash Cond: (t.store_id = s.id)
18. 0.000 0.000 ↓ 0.0

Hash Join (cost=4,073.43..244,824.87 rows=17,706 width=75) (actual rows= loops=)

  • Hash Cond: (o.order_channel_id = oc.id)
19. 0.000 0.000 ↓ 0.0

Hash Join (cost=4,072.23..244,755.31 rows=17,706 width=75) (actual rows= loops=)

  • Hash Cond: (t.transaction_origin_id = o.id)
20. 0.000 0.000 ↓ 0.0

Parallel Bitmap Heap Scan on transactions t (cost=4,070.60..244,700.17 rows=17,706 width=68) (actual rows= loops=)

  • Recheck Cond: (created_at >= '2020-09-01'::date)
  • Filter: ((deleted_at IS NULL) AND (transaction_type_id = 1))
21. 0.000 0.000 ↓ 0.0

Bitmap Index Scan on transactions_created_at_index (cost=0.00..4,059.97 rows=79,939 width=0) (actual rows= loops=)

  • Index Cond: (created_at >= '2020-09-01'::date)
22. 0.000 0.000 ↓ 0.0

Hash (cost=1.28..1.28 rows=28 width=23) (actual rows= loops=)

23. 0.000 0.000 ↓ 0.0

Seq Scan on transaction_origins o (cost=0.00..1.28 rows=28 width=23) (actual rows= loops=)

24. 0.000 0.000 ↓ 0.0

Hash (cost=1.09..1.09 rows=9 width=12) (actual rows= loops=)

25. 0.000 0.000 ↓ 0.0

Seq Scan on order_channels oc (cost=0.00..1.09 rows=9 width=12) (actual rows= loops=)

26. 0.000 0.000 ↓ 0.0

Hash (cost=4.34..4.34 rows=34 width=33) (actual rows= loops=)

27. 0.000 0.000 ↓ 0.0

Seq Scan on stores s (cost=0.00..4.34 rows=34 width=33) (actual rows= loops=)

28. 0.000 0.000 ↓ 0.0

Hash (cost=4.75..4.75 rows=75 width=30) (actual rows= loops=)

29. 0.000 0.000 ↓ 0.0

Seq Scan on transaction_statuses ts (cost=0.00..4.75 rows=75 width=30) (actual rows= loops=)

30. 0.000 0.000 ↓ 0.0

Index Scan using billing_addresses_pkey on billing_addresses ba (cost=0.43..6.06 rows=1 width=38) (actual rows= loops=)

  • Index Cond: (id = t.billing_address_id)
31. 0.000 0.000 ↓ 0.0

Index Scan using persons_pkey on persons p (cost=0.43..5.19 rows=1 width=72) (actual rows= loops=)

  • Index Cond: (id = t.person_id)
32. 0.000 0.000 ↓ 0.0

Parallel Hash (cost=8,640.71..8,640.71 rows=177,371 width=19) (actual rows= loops=)

33. 0.000 0.000 ↓ 0.0

Parallel Seq Scan on promo_codes pc (cost=0.00..8,640.71 rows=177,371 width=19) (actual rows= loops=)

34. 0.000 0.000 ↓ 0.0

Index Scan using order_totals_pkey on order_totals ot (cost=0.43..5.84 rows=1 width=16) (actual rows= loops=)

  • Index Cond: (id = t.order_total_id)
35. 0.000 0.000 ↓ 0.0

Index Scan using fiscal_notes_transactions_index on invoices (cost=0.43..4.81 rows=1 width=129) (actual rows= loops=)

  • Index Cond: (transaction_id = t.id)
  • Filter: ((deleted_at IS NULL) AND ((type)::text = 'outgoing'::text))
36. 0.000 0.000 ↓ 0.0

Index Scan using deliveries_transaction_id_index on deliveries d (cost=0.43..8.46 rows=1 width=34) (actual rows= loops=)

  • Index Cond: (transaction_id = t.id)
  • Filter: (deleted_at IS NULL)
37. 0.000 0.000 ↓ 0.0

Hash (cost=1.11..1.11 rows=11 width=18) (actual rows= loops=)

38. 0.000 0.000 ↓ 0.0

Seq Scan on delivery_statuses ds (cost=0.00..1.11 rows=11 width=18) (actual rows= loops=)