explain.depesz.com

PostgreSQL's explain analyze made readable

Result: G8iV : Optimization for: AJX; plan #qBeg

Settings

Optimization path:

Optimization(s) for this plan:

# exclusive inclusive rows x rows loops node
1. 1.922 1,679.418 ↓ 4.9 322 1

Sort (cost=47,712.29..47,712.46 rows=66 width=310) (actual time=1,679.128..1,679.418 rows=322 loops=1)

  • Sort Key: s.counttime DESC
  • Sort Method: quicksort Memory: 110kB
  • Buffers: shared hit=81,591 read=294
2. 4.563 1,677.496 ↓ 4.9 322 1

Nested Loop Left Join (cost=867.24..47,710.30 rows=66 width=310) (actual time=73.988..1,677.496 rows=322 loops=1)

  • Join Filter: (s.settlementtype_id = 8)
  • Buffers: shared hit=81,591 read=294
3. 2.768 1,669.391 ↓ 4.9 322 1

Nested Loop Left Join (cost=866.82..46,923.87 rows=66 width=241) (actual time=73.924..1,669.391 rows=322 loops=1)

  • Buffers: shared hit=80,222 read=294
4. 2.432 20.881 ↓ 4.9 322 1

Nested Loop Left Join (cost=219.43..4,194.05 rows=66 width=105) (actual time=4.242..20.881 rows=322 loops=1)

  • Buffers: shared hit=2,804 read=41
5. 12.809 15.551 ↓ 4.9 322 1

Bitmap Heap Scan on settlement s (cost=219.15..4,094.58 rows=66 width=114) (actual time=4.196..15.551 rows=322 loops=1)

  • Recheck Cond: (parentsettlement_id IS NULL)
  • Filter: ((settlementtype_id = 8) AND (COALESCE(source_moneystorage_id, sink_moneystorage_id) = '4a5b7872-31c1-11e9-9fdd-0050568b70b8'::uuid))
  • Rows Removed by Filter: 14,484
  • Heap Blocks: exact=1,835
  • Buffers: shared hit=1,838 read=41
6. 2.742 2.742 ↓ 1.0 14,806 1

Bitmap Index Scan on "IX_settlement_parentsettlement_id" (cost=0.00..219.13 rows=14,762 width=0) (actual time=2.741..2.742 rows=14,806 loops=1)

  • Index Cond: (parentsettlement_id IS NULL)
  • Buffers: shared hit=3 read=41
7. 2.898 2.898 ↑ 1.0 1 322

Index Scan using pkey_user on "user" u (cost=0.28..1.51 rows=1 width=23) (actual time=0.009..0.009 rows=1 loops=322)

  • Index Cond: (user_id = s.user_id)
  • Buffers: shared hit=966
8. 9.982 1,645.742 ↑ 1.0 1 322

Aggregate (cost=647.39..647.40 rows=1 width=136) (actual time=5.109..5.111 rows=1 loops=322)

  • Buffers: shared hit=77,418 read=253
9. 14.812 1,635.760 ↓ 1.2 6 322

Nested Loop Left Join (cost=111.26..647.31 rows=5 width=48) (actual time=4.441..5.080 rows=6 loops=322)

  • Buffers: shared hit=77,418 read=253
10. 12.880 1,595.832 ↓ 1.2 6 322

Nested Loop Left Join (cost=108.80..585.53 rows=5 width=28) (actual time=4.409..4.956 rows=6 loops=322)

  • Buffers: shared hit=71,215 read=250
11. 8.694 516.488 ↓ 1.2 6 322

Bitmap Heap Scan on settlement cs (cost=4.88..16.74 rows=5 width=60) (actual time=1.588..1.604 rows=6 loops=322)

  • Recheck Cond: ((parentsettlement_id = s.settlement_id) OR (settlement_id = s.settlement_id))
  • Filter: ((settlementtype_id = 8) AND ((parentsettlement_id = s.settlement_id) OR ((parentsettlement_id IS NULL) AND (settlement_id = s.settlement_id))))
  • Rows Removed by Filter: 0
  • Heap Blocks: exact=414
  • Buffers: shared hit=2,106 read=250
12. 2.254 507.794 ↓ 0.0 0 322

BitmapOr (cost=4.88..4.88 rows=6 width=0) (actual time=1.577..1.577 rows=0 loops=322)

  • Buffers: shared hit=1,692 read=250
13. 3.220 3.220 ↑ 1.0 5 322

Bitmap Index Scan on "IX_settlement_parentsettlement_id" (cost=0.00..2.46 rows=5 width=0) (actual time=0.010..0.010 rows=5 loops=322)

  • Index Cond: (parentsettlement_id = s.settlement_id)
  • Buffers: shared hit=973
14. 502.320 502.320 ↑ 1.0 1 322

Bitmap Index Scan on settlement_pkey (cost=0.00..2.42 rows=1 width=0) (actual time=1.560..1.560 rows=1 loops=322)

  • Index Cond: (settlement_id = s.settlement_id)
  • Buffers: shared hit=719 read=250
15. 8.925 1,066.464 ↓ 0.0 0 1,932

Nested Loop Left Join (cost=103.92..113.75 rows=1 width=8) (actual time=0.551..0.552 rows=0 loops=1,932)

  • Buffers: shared hit=69,109
16. 9.660 776.664 ↓ 0.0 0 1,932

Limit (cost=57.92..57.93 rows=1 width=717) (actual time=0.401..0.402 rows=0 loops=1,932)

  • Buffers: shared hit=62,047
17. 117.852 767.004 ↓ 0.0 0 1,932

Sort (cost=57.92..57.93 rows=1 width=717) (actual time=0.397..0.397 rows=0 loops=1,932)

  • Sort Key: s_1.counttime DESC
  • Sort Method: quicksort Memory: 25kB
  • Buffers: shared hit=62,047
18. 164.864 649.152 ↓ 27.0 27 1,932

Nested Loop (cost=2.69..57.91 rows=1 width=717) (actual time=0.101..0.336 rows=27 loops=1,932)

  • Buffers: shared hit=62,047
19. 56.028 131.376 ↓ 0.0 0 1,932

Nested Loop (cost=0.00..2.96 rows=1 width=16) (actual time=0.066..0.068 rows=0 loops=1,932)

  • Join Filter: (pt.mainpaymenttype_id = mpt.paymenttype_id)
  • Rows Removed by Join Filter: 12
  • Buffers: shared hit=3,864
20. 19.320 19.320 ↑ 1.0 1 1,932

Seq Scan on paymenttype pt (cost=0.00..1.32 rows=1 width=20) (actual time=0.007..0.010 rows=1 loops=1,932)

  • Filter: (paymenttype_id = cs.paymenttype_id)
  • Rows Removed by Filter: 25
  • Buffers: shared hit=1,932
21. 56.028 56.028 ↑ 1.2 13 1,932

Seq Scan on paymenttype mpt (cost=0.00..1.45 rows=15 width=4) (actual time=0.009..0.029 rows=13 loops=1,932)

  • Filter: isphysical
  • Rows Removed by Filter: 30
  • Buffers: shared hit=1,932
22. 309.120 352.912 ↓ 40.0 160 322

Bitmap Heap Scan on settlement s_1 (cost=2.69..54.91 rows=4 width=76) (actual time=0.180..1.096 rows=160 loops=322)

  • Recheck Cond: ((source_moneystorage_id = cs.source_moneystorage_id) AND (counttime < cs.counttime))
  • Filter: ((paymenttype_id = cs.paymenttype_id) AND (settlementtype_id = 8))
  • Rows Removed by Filter: 802
  • Heap Blocks: exact=55,762
  • Buffers: shared hit=58,183
23. 43.792 43.792 ↓ 35.7 963 322

Bitmap Index Scan on "IX_settlement_source_moneystorage_id_counttime" (cost=0.00..2.69 rows=27 width=0) (actual time=0.136..0.136 rows=963 loops=322)

  • Index Cond: ((source_moneystorage_id = cs.source_moneystorage_id) AND (counttime < cs.counttime))
  • Buffers: shared hit=2,421
24. 2.568 280.875 ↓ 0.0 0 321

Nested Loop (cost=46.00..55.80 rows=1 width=68) (actual time=0.875..0.875 rows=0 loops=321)

  • Join Filter: (COALESCE(ps.parentsettlement_id, rs_1.parentsettlement_id) = COALESCE(s_1.parentsettlement_id, s_1.settlement_id))
  • Buffers: shared hit=7,062
25. 2.889 278.307 ↓ 0.0 0 321

Bitmap Heap Scan on settlement rs_1 (cost=45.58..53.52 rows=1 width=52) (actual time=0.867..0.867 rows=0 loops=321)

  • Recheck Cond: ((source_moneystorage_id = s_1.source_moneystorage_id) AND (settlementtype_id = 2))
  • Filter: (paymenttype_id = s_1.paymenttype_id)
  • Buffers: shared hit=7,062
26. 17.655 275.418 ↓ 0.0 0 321

BitmapAnd (cost=45.58..45.58 rows=4 width=0) (actual time=0.858..0.858 rows=0 loops=321)

  • Buffers: shared hit=7,062
27. 80.250 80.250 ↓ 23.6 1,935 321

Bitmap Index Scan on "IX_settlement_source_moneystorage_id_counttime" (cost=0.00..3.03 rows=82 width=0) (actual time=0.250..0.250 rows=1,935 loops=321)

  • Index Cond: (source_moneystorage_id = s_1.source_moneystorage_id)
  • Buffers: shared hit=3,852
28. 177.513 177.513 ↓ 1.0 3,147 321

Bitmap Index Scan on settlement_settlementtype_id_idx (cost=0.00..41.53 rows=3,098 width=0) (actual time=0.553..0.553 rows=3,147 loops=321)

  • Index Cond: (settlementtype_id = 2)
  • Buffers: shared hit=3,210
29. 0.000 0.000 ↓ 0.0 0

Index Scan using settlement_pkey on settlement ps (cost=0.42..2.27 rows=1 width=32) (never executed)

  • Index Cond: (settlement_id = rs_1.parentsettlement_id)
30. 11.592 25.116 ↓ 0.0 0 1,932

Bitmap Heap Scan on settlement es (cost=2.46..12.35 rows=1 width=52) (actual time=0.013..0.013 rows=0 loops=1,932)

  • Recheck Cond: (parentsettlement_id = cs.settlement_id)
  • Filter: (settlementtype_id = 7)
  • Rows Removed by Filter: 1
  • Heap Blocks: exact=396
  • Buffers: shared hit=6,203 read=3
31. 13.524 13.524 ↑ 5.0 1 1,932

Bitmap Index Scan on "IX_settlement_parentsettlement_id" (cost=0.00..2.46 rows=5 width=0) (actual time=0.007..0.007 rows=1 loops=1,932)

  • Index Cond: (parentsettlement_id = cs.settlement_id)
  • Buffers: shared hit=5,807 read=3
32. 3.542 3.542 ↓ 0.0 0 322

Index Scan using "IX_settlement_parentsettlement_id" on settlement rs (cost=0.42..11.88 rows=1 width=56) (actual time=0.011..0.011 rows=0 loops=322)

  • Index Cond: (parentsettlement_id = s.settlement_id)
  • Filter: (settlementtype_id = 2)
  • Rows Removed by Filter: 5
  • Buffers: shared hit=1,369
Planning time : 5.089 ms
Execution time : 1,680.189 ms