explain.depesz.com

PostgreSQL's explain analyze made readable

Result: cUsO : a pablo le gusta la japi

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

Group (cost=384,934.10..384,934.22 rows=1 width=930) (actual time=1,531.768..1,531.768 rows=0 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.028 1,531.768 ↓ 0.0 0 1

Sort (cost=384,934.10..384,934.10 rows=1 width=491) (actual time=1,531.768..1,531.768 rows=0 loops=1)

  • 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
  • Sort Method: quicksort Memory: 25kB
3. 0.001 1,531.740 ↓ 0.0 0 1

Nested Loop Left Join (cost=232.26..384,934.09 rows=1 width=491) (actual time=1,531.740..1,531.740 rows=0 loops=1)

4. 0.000 1,531.739 ↓ 0.0 0 1

Nested Loop Left Join (cost=232.13..384,933.93 rows=1 width=485) (actual time=1,531.739..1,531.739 rows=0 loops=1)

5. 0.000 1,531.739 ↓ 0.0 0 1

Nested Loop Left Join (cost=231.70..384,933.48 rows=1 width=481) (actual time=1,531.739..1,531.739 rows=0 loops=1)

6. 0.001 1,531.739 ↓ 0.0 0 1

Nested Loop Left Join (cost=231.57..384,933.32 rows=1 width=450) (actual time=1,531.739..1,531.739 rows=0 loops=1)

7. 0.000 1,531.738 ↓ 0.0 0 1

Nested Loop Left Join (cost=231.42..384,933.16 rows=1 width=398) (actual time=1,531.738..1,531.738 rows=0 loops=1)

8. 0.001 1,531.738 ↓ 0.0 0 1

Nested Loop Left Join (cost=231.00..384,926.06 rows=1 width=381) (actual time=1,531.738..1,531.738 rows=0 loops=1)

9. 0.330 1,531.737 ↓ 0.0 0 1

Nested Loop Left Join (cost=230.71..384,925.35 rows=1 width=373) (actual time=1,531.737..1,531.737 rows=0 loops=1)

  • Filter: (invoices.id IS NULL)
  • Rows Removed by Filter: 199
10. 3.683 1,530.213 ↑ 18.4 199 1

Nested Loop (cost=230.28..358,938.13 rows=3,660 width=373) (actual time=664.956..1,530.213 rows=199 loops=1)

11. 0.313 1,525.495 ↑ 17.7 207 1

Nested Loop Left Join (cost=221.38..300,808.53 rows=3,660 width=290) (actual time=664.899..1,525.495 rows=207 loops=1)

12. 0.378 1,524.561 ↑ 17.7 207 1

Nested Loop Left Join (cost=221.09..297,704.19 rows=3,660 width=231) (actual time=664.888..1,524.561 rows=207 loops=1)

13. 0.200 1,522.941 ↑ 17.7 207 1

Hash Left Join (cost=220.66..269,585.07 rows=3,660 width=174) (actual time=664.873..1,522.941 rows=207 loops=1)

  • Hash Cond: (promo_codes.discount_type_id = discount_types.id)
14. 0.354 1,522.729 ↑ 17.7 207 1

Nested Loop Left Join (cost=219.61..269,554.06 rows=3,660 width=174) (actual time=664.847..1,522.729 rows=207 loops=1)

15. 0.217 1,522.375 ↑ 17.7 207 1

Nested Loop Left Join (cost=219.19..253,721.09 rows=3,660 width=158) (actual time=664.836..1,522.375 rows=207 loops=1)

16. 0.307 1,521.123 ↑ 17.7 207 1

Nested Loop (cost=218.91..252,538.18 rows=3,660 width=166) (actual time=664.820..1,521.123 rows=207 loops=1)

17. 0.795 1,519.988 ↑ 17.7 207 1

Hash Join (cost=218.64..251,410.12 rows=3,660 width=166) (actual time=664.803..1,519.988 rows=207 loops=1)

  • Hash Cond: (trocables.product_id = products.id)
18. 0.312 1,517.267 ↑ 19.7 207 1

Nested Loop (cost=24.94..251,164.53 rows=4,079 width=127) (actual time=662.857..1,517.267 rows=207 loops=1)

19. 0.487 1,516.334 ↑ 22.3 207 1

Nested Loop (cost=24.80..250,439.21 rows=4,623 width=113) (actual time=662.842..1,516.334 rows=207 loops=1)

20. 84.695 1,514.812 ↑ 23.6 207 1

Merge Join (cost=24.51..248,930.12 rows=4,875 width=105) (actual time=662.808..1,514.812 rows=207 loops=1)

  • Merge Cond: (transactions.cellphone_id = cellphones.id)
21. 0.376 956.588 ↑ 23.4 208 1

Nested Loop (cost=1.28..1,007,321.39 rows=4,875 width=90) (actual time=423.929..956.588 rows=208 loops=1)

22. 0.572 955.172 ↑ 23.4 208 1

Nested Loop (cost=0.86..996,480.58 rows=4,875 width=90) (actual time=423.907..955.172 rows=208 loops=1)

23. 952.936 952.936 ↑ 23.4 208 1

Index Scan using transactions_cellphone_id_index on transactions (cost=0.43..959,058.83 rows=4,875 width=60) (actual time=423.872..952.936 rows=208 loops=1)

  • Filter: ((NOT fiscal_note_issued) AND requires_fiscal_note AND (deleted_at IS NULL) 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[])) AND (created_at <= now()))
  • Rows Removed by Filter: 777907
24. 1.664 1.664 ↑ 1.0 1 208

Index Scan using persons_pkey on persons (cost=0.43..7.68 rows=1 width=46) (actual time=0.008..0.008 rows=1 loops=208)

  • Index Cond: (id = transactions.person_id)
  • Filter: (deleted_at IS NULL)
25. 1.040 1.040 ↑ 1.0 1 208

Index Scan using prices_pkey on prices (cost=0.42..2.22 rows=1 width=16) (actual time=0.005..0.005 rows=1 loops=208)

  • Index Cond: (id = transactions.price_id)
26. 473.529 473.529 ↑ 1.0 971,954 1

Index Scan using cellphones_pkey on cellphones (cost=0.42..89,804.56 rows=995,751 width=31) (actual time=0.026..473.529 rows=971,954 loops=1)

27. 1.035 1.035 ↑ 1.0 1 207

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=207)

  • Index Cond: (id = cellphones.trocable_id)
  • Filter: (deleted_at IS NULL)
28. 0.621 0.621 ↑ 1.0 1 207

Index Scan using cellphone_conditions_pkey on cellphone_conditions (cost=0.14..0.16 rows=1 width=22) (actual time=0.003..0.003 rows=1 loops=207)

  • Index Cond: (id = trocables.cellphone_condition_id)
  • Filter: ((deleted_at IS NULL) AND ((cellphone_condition_type)::text = 'used'::text))
29. 0.514 1.926 ↓ 1.1 2,115 1

Hash (cost=168.66..168.66 rows=2,003 width=55) (actual time=1.926..1.926 rows=2,115 loops=1)

  • Buckets: 4096 (originally 2048) Batches: 1 (originally 1) Memory Usage: 220kB
30. 0.365 1.412 ↓ 1.1 2,115 1

Hash Join (cost=94.77..168.66 rows=2,003 width=55) (actual time=0.791..1.412 rows=2,115 loops=1)

  • Hash Cond: (products.id = transaction_products.id)
31. 0.296 0.296 ↑ 1.0 2,115 1

Seq Scan on products (cost=0.00..68.33 rows=2,115 width=47) (actual time=0.015..0.296 rows=2,115 loops=1)

  • Filter: (deleted_at IS NULL)
  • Rows Removed by Filter: 118
32. 0.378 0.751 ↑ 1.0 2,115 1

Hash (cost=68.33..68.33 rows=2,115 width=8) (actual time=0.751..0.751 rows=2,115 loops=1)

  • Buckets: 4096 Batches: 1 Memory Usage: 115kB
33. 0.373 0.373 ↑ 1.0 2,115 1

Seq Scan on products transaction_products (cost=0.00..68.33 rows=2,115 width=8) (actual time=0.003..0.373 rows=2,115 loops=1)

  • Filter: (deleted_at IS NULL)
  • Rows Removed by Filter: 118
34. 0.828 0.828 ↑ 1.0 1 207

Index Only Scan using models_pkey on models (cost=0.28..0.31 rows=1 width=8) (actual time=0.004..0.004 rows=1 loops=207)

  • Index Cond: (id = products.model_id)
  • Heap Fetches: 141
35. 1.035 1.035 ↑ 1.0 1 207

Index Only Scan using category_models_pkey on category_models (cost=0.28..0.31 rows=1 width=4) (actual time=0.004..0.005 rows=1 loops=207)

  • Index Cond: (model_id = models.id)
  • Heap Fetches: 236
36. 0.000 0.000 ↓ 0.0 0 207

Index Scan using promo_codes_pkey on promo_codes (cost=0.42..4.33 rows=1 width=20) (actual time=0.000..0.000 rows=0 loops=207)

  • Index Cond: (transactions.promo_code_id = id)
  • Filter: (deleted_at IS NULL)
37. 0.004 0.012 ↑ 1.0 2 1

Hash (cost=1.02..1.02 rows=2 width=12) (actual time=0.012..0.012 rows=2 loops=1)

  • Buckets: 1024 Batches: 1 Memory Usage: 9kB
38. 0.008 0.008 ↑ 1.0 2 1

Seq Scan on discount_types (cost=0.00..1.02 rows=2 width=12) (actual time=0.007..0.008 rows=2 loops=1)

  • Filter: (deleted_at IS NULL)
39. 1.242 1.242 ↑ 1.0 1 207

Index Scan using individual_persons_pkey on individual_persons (cost=0.43..7.68 rows=1 width=57) (actual time=0.006..0.006 rows=1 loops=207)

  • Index Cond: (transactions.person_id = person_id)
  • Filter: (deleted_at IS NULL)
40. 0.621 0.621 ↓ 0.0 0 207

Index Scan using legal_persons_pkey on legal_persons (cost=0.29..0.85 rows=1 width=67) (actual time=0.003..0.003 rows=0 loops=207)

  • Index Cond: (transactions.person_id = person_id)
  • Filter: (deleted_at IS NULL)
41. 0.000 1.035 ↑ 1.0 1 207

Index Scan using deliveries_pkey on deliveries (cost=8.90..15.88 rows=1 width=91) (actual time=0.005..0.005 rows=1 loops=207)

  • Index Cond: (id = (SubPlan 1))
42.          

SubPlan (for Index Scan)

43. 0.414 2.898 ↑ 1.0 1 207

Limit (cost=8.46..8.47 rows=1 width=12) (actual time=0.014..0.014 rows=1 loops=207)

44. 0.621 2.484 ↑ 1.0 1 207

Sort (cost=8.46..8.47 rows=1 width=12) (actual time=0.012..0.012 rows=1 loops=207)

  • Sort Key: deliveries_1.created_at DESC
  • Sort Method: quicksort Memory: 25kB
45. 1.863 1.863 ↑ 1.0 1 207

Index Scan using deliveries_transaction_id_index on deliveries deliveries_1 (cost=0.43..8.45 rows=1 width=12) (actual time=0.008..0.009 rows=1 loops=207)

  • 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[])))
  • Rows Removed by Filter: 1
46. 1.194 1.194 ↑ 1.0 1 199

Index Scan using fiscal_notes_transactions_index on invoices (cost=0.43..7.09 rows=1 width=12) (actual time=0.006..0.006 rows=1 loops=199)

  • Index Cond: (transaction_id = transactions.id)
  • Filter: ((deleted_at IS NULL) AND (NOT ignore_old_listings))
  • Rows Removed by Filter: 0
47. 0.000 0.000 ↓ 0.0 0

Index Scan using memberships_transaction_id_index on memberships (cost=0.29..0.70 rows=1 width=12) (never executed)

  • Index Cond: (transaction_id = transactions.id)
48. 0.000 0.000 ↓ 0.0 0

Index Scan using transactions_accessories_transaction_id_index on transactions_accessories (cost=0.43..7.08 rows=2 width=21) (never executed)

  • Index Cond: (transactions.id = transaction_id)
  • Filter: (deleted_at IS NULL)
49. 0.000 0.000 ↓ 0.0 0

Index Scan using accessories_pkey on accessories transaction_kit (cost=0.14..0.16 rows=1 width=60) (never executed)

  • Index Cond: (transactions_accessories.accessory_id = id)
50. 0.000 0.000 ↓ 0.0 0

Index Scan using stores_pkey on stores (cost=0.14..0.16 rows=1 width=35) (never executed)

  • Index Cond: (transactions.store_id = id)
51. 0.000 0.000 ↓ 0.0 0

Index Scan using mail_tracking_codes_tracking_code_unique on mail_tracking_codes (cost=0.42..0.46 rows=1 width=16) (never executed)

  • Index Cond: ((deliveries.tracking_code)::text = (tracking_code)::text)
52. 0.000 0.000 ↓ 0.0 0

Index Scan using mail_services_pkey on mail_services (cost=0.14..0.15 rows=1 width=14) (never executed)

  • Index Cond: (id = mail_tracking_codes.mail_service_id)
Planning time : 9.035 ms
Execution time : 1,532.269 ms