explain.depesz.com

PostgreSQL's explain analyze made readable

Result: 5slC : Optimization for: plan #DdSu

Settings

Optimization path:

# exclusive inclusive rows x rows loops node
1. 0.047 33.778 ↓ 200.0 200 1

Limit (cost=134,072.59..134,072.6 rows=1 width=1,681) (actual time=33.662..33.778 rows=200 loops=1)

  • Buffers: shared hit=20567
2. 2.826 33.731 ↓ 200.0 200 1

Sort (cost=134,072.59..134,072.6 rows=1 width=1,681) (actual time=33.659..33.731 rows=200 loops=1)

  • Sort Key: document_base.number_value, document_base.number, document_base.id
  • Sort Method: top-N heapsort Memory: 287kB
  • Buffers: shared hit=20567
3. 0.783 30.905 ↓ 775.0 775 1

Nested Loop (cost=4.25..134,072.58 rows=1 width=1,681) (actual time=0.296..30.905 rows=775 loops=1)

  • Buffers: shared hit=20567
4. 1.219 30.122 ↓ 775.0 775 1

Nested Loop (cost=4.25..134,056.51 rows=1 width=1,415) (actual time=0.293..30.122 rows=775 loops=1)

  • Buffers: shared hit=20567
5. 0.712 28.903 ↓ 775.0 775 1

Nested Loop (cost=4.25..133,995.66 rows=1 width=1,407) (actual time=0.282..28.903 rows=775 loops=1)

  • Buffers: shared hit=20567
6. 0.722 28.191 ↓ 775.0 775 1

Nested Loop (cost=3.83..133,994.17 rows=1 width=1,369) (actual time=0.279..28.191 rows=775 loops=1)

  • Buffers: shared hit=20567
7. 1.066 27.469 ↓ 775.0 775 1

Nested Loop (cost=3.4..133,990.19 rows=1 width=1,218) (actual time=0.277..27.469 rows=775 loops=1)

  • Buffers: shared hit=20567
8. 0.484 24.853 ↓ 775.0 775 1

Nested Loop (cost=3.11..133,988.82 rows=1 width=1,095) (actual time=0.257..24.853 rows=775 loops=1)

  • Buffers: shared hit=18248
9. 0.478 22.044 ↓ 775.0 775 1

Nested Loop (cost=2.69..133,986.41 rows=1 width=902) (actual time=0.241..22.044 rows=775 loops=1)

  • Buffers: shared hit=15257
10. 1.072 18.466 ↓ 775.0 775 1

Nested Loop (cost=2.26..133,984.83 rows=1 width=663) (actual time=0.209..18.466 rows=775 loops=1)

  • Buffers: shared hit=12592
11. 0.506 14.294 ↓ 775.0 775 1

Nested Loop (cost=1.83..133,982.15 rows=1 width=499) (actual time=0.193..14.294 rows=775 loops=1)

  • Buffers: shared hit=9490
12. 0.827 11.463 ↓ 775.0 775 1

Nested Loop (cost=1.42..133,980.51 rows=1 width=392) (actual time=0.177..11.463 rows=775 loops=1)

  • Buffers: shared hit=6389
13. 0.443 6.761 ↓ 38.8 775 1

Nested Loop (cost=0.99..133,941.24 rows=20 width=345) (actual time=0.159..6.761 rows=775 loops=1)

  • Buffers: shared hit=3285
14. 1.467 1.467 ↑ 1.0 441 1

Index Scan using document_types_ent_id_7f9fb2f26c3ba828 on document_types document_types (cost=0.43..2,350.95 rows=447 width=152) (actual time=0.034..1.467 rows=441 loops=1)

  • Index Cond: ((document_types.ent_id = ANY ('{8210,8211,1086,1599,1600,1608,1609,1610,1611,1612,1626,1627,1628,1634,1636,1639,1640,1641,1642,1643,1677,1680,1686,1687,1221,1222,1223,1224,1225,1226,1227,1228,1229,1230,1231,1232,1233,1234,1235,1236,1237,1238,1239,1240,1241,1242,1243,1244,1245,1246,1247,1248,1249,1250,1251,1252,1253,1254,1255,1256,1257,1258,1259,1260,1261,1262,1263,1264,1265,1266,1267,1268,1269,837,838,839,843,844,845,847,851,853,856,857,858,859,860,861,862,863,864,865,866,867,868,869,870,871,872,873,874,875,876,877,878,879,880,881,882,883,884,885,887,888,889,890,891,892,893,894,895,896,897,898,899,900,901,902,903,904,905,906,907,908,909,910,911,912,913,914,915,916,917,1421,1422,1423,1433}'::integer[])) AND ((document_types.document_code)::text = 'tov_nakl'::text))
  • Buffers: shared hit=668
15. 4.851 4.851 ↑ 1.0 2 441

Index Scan using document_base_ent_id_date_formatting_state_type_idx on document_base document_base (cost=0.56..294.37 rows=2 width=193) (actual time=0.006..0.011 rows=2 loops=441)

  • Index Cond: ((document_base.type_id = document_types.id) AND (document_base.date_formatting <= '2019-12-31'::date) AND (document_base.date_formatting >= '2019-01-01'::date))
  • Filter: ((document_base.state <> 4) AND (document_base.ent_id = ANY ('{8210,8211,1086,1599,1600,1608,1609,1610,1611,1612,1626,1627,1628,1634,1636,1639,1640,1641,1642,1643,1677,1680,1686,1687,1221,1222,1223,1224,1225,1226,1227,1228,1229,1230,1231,1232,1233,1234,1235,1236,1237,1238,1239,1240,1241,1242,1243,1244,1245,1246,1247,1248,1249,1250,1251,1252,1253,1254,1255,1256,1257,1258,1259,1260,1261,1262,1263,1264,1265,1266,1267,1268,1269,837,838,839,843,844,845,847,851,853,856,857,858,859,860,861,862,863,864,865,866,867,868,869,870,871,872,873,874,875,876,877,878,879,880,881,882,883,884,885,887,888,889,890,891,892,893,894,895,896,897,898,899,900,901,902,903,904,905,906,907,908,909,910,911,912,913,914,915,916,917,1421,1422,1423,1433}'::bigint[])))
  • Buffers: shared hit=2617
16. 3.875 3.875 ↑ 1.0 1 775

Index Scan using document_invoice_pkey on document_invoice document_invoice (cost=0.43..1.95 rows=1 width=47) (actual time=0.005..0.005 rows=1 loops=775)

  • Index Cond: (document_invoice.basedocumentmodel_ptr_id = document_base.id)
  • Buffers: shared hit=3104
17. 2.325 2.325 ↑ 1.0 1 775

Index Scan using contragent_mol_pkey on contragent_mol contragent_mol (cost=0.42..1.63 rows=1 width=107) (actual time=0.003..0.003 rows=1 loops=775)

  • Index Cond: (document_base.mol_id = contragent_mol.id)
  • Buffers: shared hit=3101
18. 3.100 3.100 ↑ 1.0 1 775

Index Scan using contragent_supplier_pkey on contragent_supplier contragent_supplier (cost=0.43..2.66 rows=1 width=164) (actual time=0.004..0.004 rows=1 loops=775)

  • Index Cond: (document_base.supplier_id = contragent_supplier.id)
  • Buffers: shared hit=3102
19. 3.100 3.100 ↑ 1.0 1 775

Index Scan using contragent_corporation_pkey on contragent_corporation contragent_corporation (cost=0.42..1.58 rows=1 width=239) (actual time=0.004..0.004 rows=1 loops=775)

  • Index Cond: (contragent_supplier.corporation_id = contragent_corporation.id)
  • Buffers: shared hit=2665
20. 2.325 2.325 ↑ 1.0 1 775

Index Scan using kbk_pkey on kbk kbk (cost=0.42..2.39 rows=1 width=193) (actual time=0.002..0.003 rows=1 loops=775)

  • Index Cond: (document_base.kbk_id = kbk.id)
  • Buffers: shared hit=2991
21. 1.550 1.550 ↑ 1.0 1 775

Index Scan using kbk_activity_type_pkey on kbk_activity_type kbk_activity_type (cost=0.29..1.37 rows=1 width=123) (actual time=0.002..0.002 rows=1 loops=775)

  • Index Cond: (document_base.kvd_id = kbk_activity_type.id)
  • Buffers: shared hit=2319
22. 0.000 0.000 ↓ 0.0 0 775

Index Scan using unidictrec_pkey on unidictrec unidictrec (cost=0.43..3.97 rows=1 width=151) (actual time=0..0 rows=0 loops=775)

  • Index Cond: (document_base.kvd_analytic_id = unidictrec.id)
23. 0.000 0.000 ↓ 0.0 0 775

Index Scan using contract_pkey on contract contract (cost=0.42..1.48 rows=1 width=38) (actual time=0..0 rows=0 loops=775)

  • Index Cond: (document_invoice.contract_id = contract.id)
24. 0.000 0.000 ↓ 0.0 0 775

Seq Scan on external_relation_with_document external_relation_with_document (cost=0..32.6 rows=2,260 width=8) (actual time=0..0 rows=0 loops=775)

25. 0.000 0.000 ↓ 0.0 0 775

Seq Scan on doc_external_relation doc_external_relation (cost=0..12.7 rows=270 width=266) (actual time=0..0 rows=0 loops=775)