explain.depesz.com

PostgreSQL's explain analyze made readable

Result: Oe4p

Settings
# exclusive inclusive rows x rows loops node
1. 0.005 3,267.686 ↑ 1.0 20 1

Limit (cost=4,537,359.69..4,537,360.99 rows=20 width=861) (actual time=3,267.643..3,267.686 rows=20 loops=1)

2. 0.022 3,267.681 ↑ 12,263.9 20 1

Unique (cost=4,537,359.69..4,553,302.70 rows=245,277 width=861) (actual time=3,267.642..3,267.681 rows=20 loops=1)

3. 443.451 3,267.659 ↑ 12,263.9 20 1

Sort (cost=4,537,359.69..4,537,972.88 rows=245,277 width=861) (actual time=3,267.639..3,267.659 rows=20 loops=1)

  • Sort Key: orders0_.order_date DESC, orders0_.id DESC, orders0_.receipt_number, orders0_.delivery_date, orders0_.gross_total, orders0_.vat_total, orders0_.vat_included_total, orders0_.manual_discount_rate, orders0_.manual_discount_amount, orders0_.discount_total, customer4_.name, customerbr3_.name, distributo6_.name, orders0_.is_synced, orders0_.sync_message, orders0_.order_status, orders0_.invoice_status, orders0_.waybill_status, salesman1_.first_name, salesman1_.last_name, orders0_.cancelled, customer4_.is_e_bill_customer, orders0_.order_type, orders0_.printed_count, ((SubPlan 2))
  • Sort Method: external merge Disk: 51,856kB
4. 1,036.125 2,824.208 ↑ 1.0 244,738 1

Hash Join (cost=185,847.91..4,329,286.43 rows=245,277 width=861) (actual time=733.974..2,824.208 rows=244,738 loops=1)

  • Hash Cond: (orders0_.distributor_id = distributo6_.id)
5. 97.615 1,543.304 ↑ 1.0 244,738 1

Hash Left Join (cost=185,843.94..250,231.84 rows=245,277 width=349) (actual time=733.807..1,543.304 rows=244,738 loops=1)

  • Hash Cond: (orders0_.salesman_id = salesman1_.id)
6. 228.464 1,429.322 ↑ 1.0 244,738 1

Hash Join (cost=183,849.74..247,591.02 rows=245,277 width=337) (actual time=717.409..1,429.322 rows=244,738 loops=1)

  • Hash Cond: (orders0_.customer_id = customer4_.id)
7. 244.085 1,121.069 ↑ 1.0 244,738 1

Hash Left Join (cost=165,473.19..207,324.60 rows=245,277 width=308) (actual time=637.195..1,121.069 rows=244,738 loops=1)

  • Hash Cond: (orders0_.customer_branch_id = customerbr3_.id)
8. 240.432 240.432 ↑ 1.0 244,738 1

Seq Scan on orders orders0_ (cost=0.00..21,359.53 rows=245,277 width=290) (actual time=0.030..240.432 rows=244,738 loops=1)

  • Filter: ((NOT is_deleted) AND (distributor_id = ANY ('{1,2,3,4,5,6,7}'::bigint[])))
  • Rows Removed by Filter: 27,491
9. 15.813 636.552 ↑ 1.8 54,802 1

Hash (cost=163,538.53..163,538.53 rows=100,053 width=26) (actual time=636.551..636.552 rows=54,802 loops=1)

  • Buckets: 65,536 Batches: 2 Memory Usage: 2,139kB
10. 620.739 620.739 ↑ 1.8 54,802 1

Seq Scan on customer_branch customerbr3_ (cost=0.00..163,538.53 rows=100,053 width=26) (actual time=0.026..620.739 rows=54,802 loops=1)

11. 9.907 79.789 ↑ 4.2 30,320 1

Hash (cost=15,655.02..15,655.02 rows=127,802 width=45) (actual time=79.788..79.789 rows=30,320 loops=1)

  • Buckets: 65,536 Batches: 4 Memory Usage: 1,125kB
12. 69.882 69.882 ↑ 4.2 30,320 1

Seq Scan on customer customer4_ (cost=0.00..15,655.02 rows=127,802 width=45) (actual time=0.040..69.882 rows=30,320 loops=1)

13. 0.171 16.367 ↑ 1.6 636 1

Hash (cost=1,981.87..1,981.87 rows=987 width=28) (actual time=16.366..16.367 rows=636 loops=1)

  • Buckets: 1,024 Batches: 1 Memory Usage: 46kB
14. 16.196 16.196 ↑ 1.6 636 1

Seq Scan on salesman salesman1_ (cost=0.00..1,981.87 rows=987 width=28) (actual time=0.010..16.196 rows=636 loops=1)

15. 0.012 0.041 ↑ 1.0 43 1

Hash (cost=3.43..3.43 rows=43 width=20) (actual time=0.041..0.041 rows=43 loops=1)

  • Buckets: 1,024 Batches: 1 Memory Usage: 11kB
16. 0.029 0.029 ↑ 1.0 43 1

Seq Scan on distributor distributo6_ (cost=0.00..3.43 rows=43 width=20) (actual time=0.010..0.029 rows=43 loops=1)

17.          

SubPlan (for Hash Join)

18. 0.000 244.738 ↑ 1.0 1 244,738

Index Scan using district_pkey on district district10_ (cost=8.61..16.63 rows=1 width=8) (actual time=0.001..0.001 rows=1 loops=244,738)

  • Index Cond: (id = $1)
19.          

Initplan (for Index Scan)

20. 244.738 734.214 ↑ 1.0 1 244,738

Aggregate (cost=8.31..8.32 rows=1 width=8) (actual time=0.003..0.003 rows=1 loops=244,738)

21. 489.476 489.476 ↑ 1.0 1 244,738

Index Scan using customer_branch_address_ids on customer_branch_address customerbr11_ (cost=0.29..8.31 rows=1 width=8) (actual time=0.002..0.002 rows=1 loops=244,738)

  • Index Cond: (customer_branch_id = customerbr3_.id)
  • Filter: ((address_type)::text = 'INVOICE_ADDRESS'::text)
  • Rows Removed by Filter: 0
Planning time : 4.727 ms
Execution time : 3,278.037 ms