explain.depesz.com

PostgreSQL's explain analyze made readable

Result: msCb : a pablo le gusta la galletita

Settings
# exclusive inclusive rows x rows loops node
1. 0.216 1,153.856 ↓ 29.0 29 1

Group (cost=4,815.66..4,815.78 rows=1 width=3,034) (actual time=1,153.688..1,153.856 rows=29 loops=1)

  • Group Key: transactions.id, individual_persons.person_id, legal_persons.person_id, deliveries.cep, deliveries.city, deliveries.state_code, deliveries.address, deliveries.number, deliveries.quarter, deliveries.adjunct, persons.phone_number, persons.email, prices.value, discount_types.name, promo_codes.amount, deliveries.price, deliveries.tracking_code, cellphones.imei, products.id, memberships.total, transactions_accessories.id, stores.id, mail_services.name, transaction_kit.name, transaction_kit.tiny_code, cellphone_conditions.id
2. 0.131 1,153.640 ↓ 29.0 29 1

Sort (cost=4,815.66..4,815.66 rows=1 width=6,099) (actual time=1,153.632..1,153.640 rows=29 loops=1)

  • Sort Method: quicksort Memory: 39kB
  • Sort Key: transactions.id, individual_persons.person_id, legal_persons.person_id, deliveries.cep, deliveries.city, deliveries.state_code, deliveries.address, deliveries.number, deliveries.quarter, deliveries.adjunct, persons.phone_number, persons.email, prices.value, discount_types.name, promo_codes.amount, deliveries.price, deliveries.tracking_code, cellphones.imei, products.id, memberships.total, transactions_accessories.id, stores.id, mail_services.name, transaction_kit.name, transaction_kit.tiny_code, cellphone_conditions.id
3. 0.086 1,153.509 ↓ 29.0 29 1

Nested Loop Left Join (cost=285.72..4,815.65 rows=1 width=6,099) (actual time=562.548..1,153.509 rows=29 loops=1)

4. 1,153.365 1,153.365 ↓ 29.0 29 1

Nested Loop Left Join (cost=285.59..4,815.49 rows=1 width=5,587) (actual time=562.538..1,153.365 rows=29 loops=1)

5. 0.000 0.058 ↑ 1.0 1 29

Index Scan using mail_services_pkey on mail_services (cost=0.14..0.15 rows=1 width=520) (actual time=0.002..0.002 rows=1 loops=29)

  • Index Cond: (id = mail_tracking_codes.mail_service_id)
6. 1,152.940 1,152.940 ↓ 29.0 29 1

Nested Loop Left Join (cost=285.17..4,815.04 rows=1 width=5,583) (actual time=562.513..1,152.940 rows=29 loops=1)

7. 0.000 0.348 ↑ 1.0 1 29

Index Scan using mail_tracking_codes_tracking_code_unique on mail_tracking_codes (cost=0.42..0.45 rows=1 width=520) (actual time=0.012..0.012 rows=1 loops=29)

  • Rows Removed by Join Filter: 71
  • Join Filter: (transactions.store_id = stores.id)
  • Index Cond: ((deliveries.tracking_code)::text = (tracking_code)::text)
8. 0.087 0.087 ↑ 7.7 3 29

Seq Scan on stores (cost=0.00..2.23 rows=23 width=33) (actual time=0.003..0.003 rows=3 loops=29)

9. 0.080 1,152.734 ↓ 29.0 29 1

Nested Loop Left Join (cost=285.17..4,812.52 rows=1 width=5,554) (actual time=562.501..1,152.734 rows=29 loops=1)

10. 1,152.654 1,152.654 ↓ 29.0 29 1

Nested Loop Left Join (cost=285.03..4,812.37 rows=1 width=5,422) (actual time=562.494..1,152.654 rows=29 loops=1)

11. 0.000 0.000 ↓ 0.0 0 29

Index Scan using accessories_pkey on accessories transaction_kit (cost=0.14..0.15 rows=1 width=140) (actual time=0.000..0.000 rows=0 loops=29)

  • Index Cond: (transactions_accessories.accessory_id = id)
12. 1,152.457 1,152.457 ↓ 29.0 29 1

Nested Loop Left Join (cost=284.61..4,800.13 rows=1 width=5,405) (actual time=562.475..1,152.457 rows=29 loops=1)

13. 0.000 0.116 ↓ 0.0 0 29

Index Scan using transactions_accessories_transaction_id_index on transactions_accessories (cost=0.42..12.22 rows=2 width=21) (actual time=0.004..0.004 rows=0 loops=29)

  • Index Cond: (transactions.id = transaction_id)
  • Filter: (deleted_at IS NULL)
14. 1,152.242 1,152.242 ↓ 29.0 29 1

Nested Loop Left Join (cost=279.04..4,508.03 rows=1 width=5,397) (actual time=562.462..1,152.242 rows=29 loops=1)

15. 0.000 0.116 ↓ 0.0 0 29

Bitmap Heap Scan on memberships (cost=5.57..290.45 rows=165 width=12) (actual time=0.004..0.004 rows=0 loops=29)

  • Rows Removed by Filter: 151
  • Recheck Cond: (transaction_id = transactions.id)
  • Filter: (invoices.id IS NULL)
16. 1,150.507 1,150.507 ↓ 180.0 180 1

Nested Loop (cost=252.94..445.74 rows=1 width=5,397) (actual time=550.027..1,150.507 rows=180 loops=1)

17. 0.087 0.087 ↓ 0.0 0 29

Bitmap Index Scan on memberships_transaction_id_index (cost=0.00..5.53 rows=165 width=0) (actual time=0.003..0.003 rows=0 loops=29)

18. 0.000 1.260 ↑ 3.0 1 180

Bitmap Heap Scan on invoices (cost=26.10..4,062.26 rows=3 width=12) (actual time=0.006..0.007 rows=1 loops=180)

  • Rows Removed by Filter: 0
  • Recheck Cond: (transaction_id = transactions.id)
  • Index Cond: (transaction_id = transactions.id)
  • Heap Blocks: exact=210
  • Filter: ((deleted_at IS NULL) AND (NOT ignore_old_listings))
19. 1,147.139 1,147.139 ↓ 188.0 188 1

Nested Loop Left Join (cost=244.05..428.84 rows=1 width=5,315) (actual time=549.979..1,147.139 rows=188 loops=1)

20. 0.752 0.752 ↑ 1.0 1 188

Index Scan using deliveries_pkey on deliveries (cost=8.89..16.91 rows=1 width=90) (actual time=0.004..0.004 rows=1 loops=188)

21. 0.000 0.540 ↑ 1,291.0 1 180

Bitmap Index Scan on fiscal_notes_transactions_index (cost=0.00..26.10 rows=1,291 width=0) (actual time=0.003..0.003 rows=1 loops=180)

  • Index Cond: (transaction_id = transactions.id)
  • Index Cond: (id = (SubPlan 1))
22. 1,146.396 1,146.396 ↓ 188.0 188 1

Nested Loop Left Join (cost=243.77..420.10 rows=1 width=3,767) (actual time=549.967..1,146.396 rows=188 loops=1)

23. 0.000 0.376 ↓ 0.0 0 188

Index Scan using legal_persons_person_id_index on legal_persons (cost=0.28..8.30 rows=1 width=1,556) (actual time=0.002..0.002 rows=0 loops=188)

24. 0.000 2.068 ↑ 1.0 1 188

Limit (cost=8.46..8.46 rows=1 width=12) (actual time=0.010..0.011 rows=1 loops=188)

  • Index Cond: (transactions.person_id = person_id)
  • Filter: (deleted_at IS NULL)
25. 1,145.013 1,145.013 ↓ 188.0 188 1

Nested Loop Left Join (cost=243.34..411.66 rows=1 width=1,695) (actual time=549.952..1,145.013 rows=188 loops=1)

26. 0.000 1.128 ↑ 1.0 1 188

Index Scan using individual_persons_person_id_index on individual_persons (cost=0.43..8.45 rows=1 width=2,072) (actual time=0.006..0.006 rows=1 loops=188)

27. 0.000 1.692 ↑ 1.0 1 188

Sort (cost=8.46..8.46 rows=1 width=12) (actual time=0.008..0.009 rows=1 loops=188)

  • Index Cond: (transactions.person_id = person_id)
  • Filter: (deleted_at IS NULL)
28. 1,144.137 1,144.137 ↓ 188.0 188 1

Nested Loop (cost=243.19..411.42 rows=1 width=1,703) (actual time=549.941..1,144.137 rows=188 loops=1)

29. 0.000 0.564 ↑ 1.0 1 188

Index Only Scan using category_models_pkey on category_models (cost=0.15..0.22 rows=1 width=4) (actual time=0.003..0.003 rows=1 loops=188)

  • Sort Method: quicksort Memory: 25kB
  • Sort Key: deliveries_1.created_at DESC
30. 0.000 1.128 ↑ 1.0 1 188

Index Scan using deliveries_transaction_id_index on deliveries deliveries_1 (cost=0.42..8.45 rows=1 width=12) (actual time=0.005..0.006 rows=1 loops=188)

  • Index Cond: (model_id = models.id)
  • Heap Fetches: 188
31. 1,143.355 1,143.355 ↓ 188.0 188 1

Nested Loop Left Join (cost=243.04..405.22 rows=1 width=1,703) (actual time=549.925..1,143.355 rows=188 loops=1)

32. 0.000 0.376 ↑ 1.0 1 188

Index Only Scan using models_pkey on models (cost=0.15..6.17 rows=1 width=8) (actual time=0.002..0.002 rows=1 loops=188)

  • Rows Removed by Filter: 0
  • Index Cond: (transaction_id = transactions.id)
  • Filter: ((deleted_at IS NULL) AND (((delivery_type)::text <> 'pickup'::text) OR (delivery_type IS NULL)) AND (delivery_status_id = ANY ('{2,3,4}'::integer[])))
  • Index Cond: (id = products.model_id)
  • Heap Fetches: 188
33. 0.188 0.188 ↓ 0.0 0 188

Nested Loop Left Join (cost=0.42..8.55 rows=1 width=44) (actual time=0.001..0.001 rows=0 loops=188)

34. 0.319 1,142.870 ↓ 188.0 188 1

Nested Loop (cost=242.63..396.66 rows=1 width=1,663) (actual time=549.917..1,142.870 rows=188 loops=1)

35. 1,141.611 1,141.611 ↓ 188.0 188 1

Nested Loop (cost=242.33..388.35 rows=1 width=1,663) (actual time=549.906..1,141.611 rows=188 loops=1)

36. 0.000 0.000 ↓ 0.0 0 188

Index Scan using promo_codes_pkey on promo_codes (cost=0.29..8.31 rows=1 width=20) (actual time=0.000..0.000 rows=0 loops=188)

37. 0.940 0.940 ↑ 1.0 1 188

Index Scan using prices_pkey on prices (cost=0.29..8.31 rows=1 width=16) (actual time=0.005..0.005 rows=1 loops=188)

38. 0.000 0.000 ↓ 0.0 0

Index Scan using discount_types_pkey on discount_types (cost=0.13..0.18 rows=1 width=36) (never executed)

  • Index Cond: (transactions.promo_code_id = id)
  • Index Cond: (promo_codes.discount_type_id = id)
  • Index Cond: (id = transactions.price_id)
  • Filter: (deleted_at IS NULL)
  • Filter: (deleted_at IS NULL)
39. 1,141.021 1,141.021 ↓ 188.0 188 1

Nested Loop (cost=242.06..386.59 rows=1 width=1,671) (actual time=549.899..1,141.021 rows=188 loops=1)

40. 0.000 0.376 ↑ 1.0 1 188

Index Scan using products_pkey on products transaction_products (cost=0.28..1.34 rows=1 width=8) (actual time=0.002..0.002 rows=1 loops=188)

  • Index Cond: (id = trocables.product_id)
  • Filter: (deleted_at IS NULL)
41. 1,140.329 1,140.329 ↓ 188.0 188 1

Nested Loop (cost=241.92..386.06 rows=1 width=1,639) (actual time=549.887..1,140.329 rows=188 loops=1)

42. 0.000 0.376 ↑ 1.0 1 188

Index Scan using cellphone_conditions_pkey on cellphone_conditions (cost=0.14..0.33 rows=1 width=40) (actual time=0.002..0.002 rows=1 loops=188)

  • Index Cond: (id = trocables.cellphone_condition_id)
  • Filter: ((deleted_at IS NULL) AND ((cellphone_condition_type)::text = 'used'::text))
43. 1,139.496 1,139.496 ↓ 188.0 188 1

Nested Loop (cost=241.65..384.30 rows=1 width=1,107) (actual time=549.876..1,139.496 rows=188 loops=1)

44. 0.000 0.564 ↑ 1.0 1 188

Index Scan using products_pkey on products (cost=0.28..1.34 rows=1 width=532) (actual time=0.003..0.003 rows=1 loops=188)

  • Index Cond: (id = trocables.product_id)
  • Filter: (deleted_at IS NULL)
45. 1,138.331 1,138.331 ↓ 188.0 188 1

Nested Loop (cost=241.36..383.99 rows=1 width=1,099) (actual time=549.864..1,138.331 rows=188 loops=1)

46. 0.000 0.940 ↑ 1.0 1 188

Index Scan using trocables_pkey on trocables (cost=0.29..0.31 rows=1 width=24) (actual time=0.005..0.005 rows=1 loops=188)

  • Index Cond: (id = cellphones.trocable_id)
  • Filter: (deleted_at IS NULL)
47. 1,137.076 1,137.076 ↓ 260.0 260 1

Nested Loop (cost=240.94..375.56 rows=1 width=1,084) (actual time=549.538..1,137.076 rows=260 loops=1)

48. 0.000 0.780 ↑ 1.0 1 260

Index Scan using cellphones_pkey on cellphones (cost=0.42..8.44 rows=1 width=31) (actual time=0.003..0.003 rows=1 loops=260)

  • Index Cond: (id = transactions.cellphone_id)
49. 1.820 1.820 ↑ 1.0 1 260

Index Scan using persons_pkey on persons (cost=0.43..8.45 rows=1 width=1,040) (actual time=0.007..0.007 rows=1 loops=260)

50. 598.706 1,134.651 ↓ 260.0 260 1

Bitmap Heap Scan on transactions (cost=240.51..367.11 rows=1 width=60) (actual time=549.512..1,134.651 rows=260 loops=1)

  • Rows Removed by Filter: 1256610
  • Recheck Cond: ((deleted_at IS NULL) AND (created_at <= now()) AND (created_at > (now() - '16 years'::interval)))
  • Index Cond: (id = transactions.person_id)
  • Heap Blocks: exact=51013
  • Filter: (deleted_at IS NULL)
  • Filter: ((NOT fiscal_note_issued) AND requires_fiscal_note AND ((payment_method_external_type IS NULL) OR (payment_method_external_type <> 'TOTVS'::text)) AND (transaction_origin_id = 4) AND (transaction_status_id = ANY ('{3,50,37}'::bigint[])))
51. 6.430 535.945 ↓ 0.0 0 1

BitmapAnd (cost=240.51..240.51 rows=32 width=0) (actual time=535.945..535.945 rows=0 loops=1)

52. 102.198 102.198 ↓ 201.4 1,281,005 1

Bitmap Index Scan on transactions_delete_at_is_null_index (cost=0.00..104.23 rows=6,360 width=0) (actual time=102.198..102.198 rows=1,281,005 loops=1)

53. 427.317 427.317 ↓ 201.4 1,281,007 1

Bitmap Index Scan on transactions_created_at_index (cost=0.00..136.03 rows=6,360 width=0) (actual time=427.317..427.317 rows=1,281,007 loops=1)

  • Index Cond: ((created_at <= now()) AND (created_at > (now() - '16 years'::interval)))
Planning time : 16.359 ms
Execution time : 1,159.392 ms