explain.depesz.com

PostgreSQL's explain analyze made readable

Result: 5uAT

Settings
# exclusive inclusive rows x rows loops node
1. 0.000 4,880.655 ↑ 1.0 100 1

Limit (cost=329,574.93..329,575.18 rows=100 width=141) (actual time=4,880.599..4,880.655 rows=100 loops=1)

2.          

Initplan (forLimit)

3. 42.843 132.188 ↑ 1.0 1 1

Aggregate (cost=23,975.91..23,975.92 rows=1 width=32) (actual time=132.187..132.188 rows=1 loops=1)

4. 89.345 89.345 ↓ 1.0 188,989 1

Index Only Scan using payment_customer_id_index on payment payment_1 (cost=0.43..23,504.84 rows=188,424 width=4) (actual time=0.039..89.345 rows=188,989 loops=1)

  • Index Cond: (customer_id IS NOT NULL)
  • Heap Fetches: 40655
5. 60.257 4,880.616 ↑ 378.5 100 1

Sort (cost=305,599.02..305,693.64 rows=37,847 width=141) (actual time=4,880.597..4,880.616 rows=100 loops=1)

  • Sort Key: payment.last_status_created DESC
  • Sort Method: top-N heapsort Memory: 52kB
6. 30.724 4,820.359 ↓ 1.8 66,699 1

Hash Left Join (cost=242,309.60..304,152.53 rows=37,847 width=141) (actual time=2,911.813..4,820.359 rows=66,699 loops=1)

  • Hash Cond: (payment.customer_id = list_customer_by_id.id)
7. 28.226 4,262.381 ↓ 1.8 66,699 1

Hash Left Join (cost=242,286.85..299,287.93 rows=37,847 width=126) (actual time=2,384.548..4,262.381 rows=66,699 loops=1)

  • Hash Cond: (payment_card.terminal_id = terminal.id)
8. 35.072 4,234.129 ↓ 1.8 66,699 1

Hash Left Join (cost=242,285.15..299,115.38 rows=37,847 width=121) (actual time=2,384.504..4,234.129 rows=66,699 loops=1)

  • Hash Cond: (payment.id = payment_agent_to_agent.payment_id)
9. 36.973 4,196.891 ↓ 1.8 66,699 1

Hash Left Join (cost=242,195.72..298,926.59 rows=37,847 width=117) (actual time=2,382.324..4,196.891 rows=66,699 loops=1)

  • Hash Cond: (payment.id = payment_transfer.payment_id)
10. 140.259 4,142.382 ↓ 1.8 66,699 1

Hash Left Join (cost=241,590.93..298,174.48 rows=37,847 width=109) (actual time=2,364.751..4,142.382 rows=66,699 loops=1)

  • Hash Cond: (payment.deal_id = deal_customer.deal_id)
11. 97.881 3,840.685 ↓ 1.8 66,699 1

Hash Left Join (cost=233,501.33..287,711.53 rows=37,847 width=92) (actual time=2,203.203..3,840.685 rows=66,699 loops=1)

  • Hash Cond: (payment.id = payment_card.payment_id)
12. 364.380 3,650.053 ↓ 1.8 66,699 1

Hash Left Join (cost=229,640.51..282,051.60 rows=37,847 width=82) (actual time=2,110.353..3,650.053 rows=66,699 loops=1)

  • Hash Cond: (payment.pair_id = payment_pair.id)
13. 611.036 1,429.060 ↓ 1.8 66,699 1

Hash Right Join (cost=82,010.95..127,632.69 rows=37,847 width=78) (actual time=253.662..1,429.060 rows=66,699 loops=1)

  • Hash Cond: (deal.id = payment.deal_id)
14. 564.581 564.581 ↓ 1.0 1,082,377 1

Seq Scan on deal (cost=0.00..25,360.37 rows=1,082,337 width=17) (actual time=0.017..564.581 rows=1,082,377 loops=1)

15. 66.266 253.443 ↓ 1.8 66,699 1

Hash (cost=81,093.86..81,093.86 rows=37,847 width=65) (actual time=253.442..253.443 rows=66,699 loops=1)

  • Buckets: 65536 Batches: 2 Memory Usage: 3166kB
16. 172.529 187.177 ↓ 1.8 66,699 1

Bitmap Heap Scan on payment (cost=4,084.39..81,093.86 rows=37,847 width=65) (actual time=17.380..187.177 rows=66,699 loops=1)

  • Recheck Cond: ((agent_id = 1) AND (office_id = 15))
  • Filter: (last_status_created < '2019-02-06 22:00:00+00'::timestamp with time zone)
  • Heap Blocks: exact=12990
17. 14.648 14.648 ↓ 1.8 66,704 1

Bitmap Index Scan on payment_agent_id_office_id_index (cost=0.00..4,074.93 rows=37,850 width=0) (actual time=14.648..14.648 rows=66,704 loops=1)

  • Index Cond: ((agent_id = 1) AND (office_id = 15))
18. 666.615 1,856.613 ↑ 1.0 1,448,632 1

Hash (cost=123,572.36..123,572.36 rows=1,466,336 width=8) (actual time=1,856.612..1,856.613 rows=1,448,632 loops=1)

  • Buckets: 131072 Batches: 32 Memory Usage: 2797kB
19. 1,189.998 1,189.998 ↑ 1.0 1,448,632 1

Seq Scan on payment payment_pair (cost=0.00..123,572.36 rows=1,466,336 width=8) (actual time=0.040..1,189.998 rows=1,448,632 loops=1)

20. 53.125 92.751 ↑ 1.0 120,792 1

Hash (cost=1,760.92..1,760.92 rows=120,792 width=14) (actual time=92.751..92.751 rows=120,792 loops=1)

  • Buckets: 131072 Batches: 2 Memory Usage: 3207kB
21. 39.626 39.626 ↑ 1.0 120,792 1

Seq Scan on payment_card (cost=0.00..1,760.92 rows=120,792 width=14) (actual time=0.029..39.626 rows=120,792 loops=1)

22. 89.179 161.438 ↑ 1.0 198,435 1

Hash (cost=4,443.60..4,443.60 rows=198,560 width=21) (actual time=161.438..161.438 rows=198,435 loops=1)

  • Buckets: 65536 Batches: 4 Memory Usage: 2702kB
23. 72.259 72.259 ↑ 1.0 198,435 1

Seq Scan on deal_customer (cost=0.00..4,443.60 rows=198,560 width=21) (actual time=0.020..72.259 rows=198,435 loops=1)

24. 9.732 17.536 ↓ 1.0 20,929 1

Hash (cost=343.24..343.24 rows=20,924 width=12) (actual time=17.535..17.536 rows=20,929 loops=1)

  • Buckets: 32768 Batches: 1 Memory Usage: 1098kB
25. 7.804 7.804 ↓ 1.0 20,929 1

Seq Scan on payment_transfer (cost=0.00..343.24 rows=20,924 width=12) (actual time=0.016..7.804 rows=20,929 loops=1)

26. 1.107 2.166 ↓ 1.0 3,176 1

Hash (cost=49.75..49.75 rows=3,175 width=8) (actual time=2.166..2.166 rows=3,176 loops=1)

  • Buckets: 4096 Batches: 1 Memory Usage: 157kB
27. 1.059 1.059 ↓ 1.0 3,176 1

Seq Scan on payment_agent_to_agent (cost=0.00..49.75 rows=3,175 width=8) (actual time=0.033..1.059 rows=3,176 loops=1)

28. 0.012 0.026 ↑ 1.0 31 1

Hash (cost=1.31..1.31 rows=31 width=25) (actual time=0.026..0.026 rows=31 loops=1)

  • Buckets: 1024 Batches: 1 Memory Usage: 10kB
29. 0.014 0.014 ↑ 1.0 31 1

Seq Scan on terminal (cost=0.00..1.31 rows=31 width=25) (actual time=0.008..0.014 rows=31 loops=1)

30. 18.447 527.254 ↓ 42.8 42,846 1

Hash (cost=10.25..10.25 rows=1,000 width=36) (actual time=527.254..527.254 rows=42,846 loops=1)

  • Buckets: 65536 (originally 1024) Batches: 1 (originally 1) Memory Usage: 3031kB
31. 508.807 508.807 ↓ 42.8 42,846 1

Function Scan on list_customer_by_id (cost=0.25..10.25 rows=1,000 width=36) (actual time=496.725..508.807 rows=42,846 loops=1)