explain.depesz.com

PostgreSQL's explain analyze made readable

Result: o33B

Settings

Optimization(s) for this plan:

# exclusive inclusive rows x rows loops node
1. 159.300 3,620.090 ↑ 4.5 6,442 1

Unique (cost=10,412.31..12,666.32 rows=29,084 width=143) (actual time=3,373.496..3,620.090 rows=6,442 loops=1)

2. 2,953.691 3,460.790 ↓ 7.9 228,667 1

Sort (cost=10,412.31..10,485.02 rows=29,084 width=143) (actual time=3,373.494..3,460.790 rows=228,667 loops=1)

  • Sort Key: phdrug_phdrug.default_description, phdrug_phdrug.id, phdrug_phdrug.uuid, phdrug_phdrug.ean, phdrug_phdrug.parent_ean, phdrug_phdrug.reg_num, phdrug_phdrug.medika_code, phdrug_phdrug.atc_iv, phdrug_phdrug.product_type, phdrug_phdrug.fraction, phdrug_phdrug.active, phdrug_phdrug.loyal, phdrug_phdrug.patent, phdrug_phdrug.chronics, phdrug_phdrug.recipe, phdrug_phdrug.deal, phdrug_phdrug.specialized, phdrug_phdrug.armored, phdrug_phdrug.hight_speciality, phdrug_phdrug.temp_8_15, phdrug_phdrug.temp_15_25, phdrug_phdrug.temp_2_8, phdrug_phdrug.temp_less_15, phdrug_phdrug.new, phdrug_phdrug.mdk_internal_code, phdrug_phdrug.mdk_single_id, phdrug_phdrug.is_from_mdk_db, phdrug_phdrug.top, phdrug_phdrug.laboratory_id, phdrug_phdrug.specialty_id
  • Sort Method: external merge Disk: 31,192kB
3. 89.712 507.099 ↓ 7.9 228,667 1

Hash Join (cost=704.51..6,166.54 rows=29,084 width=143) (actual time=23.648..507.099 rows=228,667 loops=1)

  • Hash Cond: (monetary_drugprice.pricelist_id = monetary_pricelist.id)
4. 165.596 416.630 ↓ 10.4 457,692 1

Nested Loop (cost=696.92..5,604.95 rows=44,105 width=147) (actual time=22.881..416.630 rows=457,692 loops=1)

  • Join Filter: (phdrug_phdrug.id = monetary_drugprice.drug_id)
5. 12.909 38.841 ↓ 5.1 23,577 1

Hash Join (cost=696.51..1,177.21 rows=4,583 width=147) (actual time=22.864..38.841 rows=23,577 loops=1)

  • Hash Cond: (phdrug_phdrug.id = t4.drug_id)
6. 3.593 3.593 ↑ 1.0 11,992 1

Seq Scan on phdrug_phdrug (cost=0.00..359.94 rows=11,992 width=143) (actual time=0.438..3.593 rows=11,992 loops=1)

  • Filter: active
  • Rows Removed by Filter: 2
7. 5.637 22.339 ↓ 5.1 23,577 1

Hash (cost=639.21..639.21 rows=4,584 width=4) (actual time=22.339..22.339 rows=23,577 loops=1)

  • Buckets: 32,768 (originally 8192) Batches: 1 (originally 1) Memory Usage: 1,085kB
8. 6.176 16.702 ↓ 5.1 23,577 1

Nested Loop (cost=3.99..639.21 rows=4,584 width=4) (actual time=1.785..16.702 rows=23,577 loops=1)

9. 0.028 1.874 ↓ 1.4 7 1

Nested Loop (cost=3.58..9.11 rows=5 width=8) (actual time=1.756..1.874 rows=7 loops=1)

10. 0.078 1.797 ↓ 1.4 7 1

Hash Left Join (cost=3.43..7.57 rows=5 width=4) (actual time=1.733..1.797 rows=7 loops=1)

  • Hash Cond: (monetary_pricelistdestinations.to_organization_data_id = organization_organizationdata.id)
  • Filter: (monetary_pricelistdestinations.to_all_insurances OR (organization_organization.uuid = 'b51773d4-05f8-43a2-86ef-0098b31725d8'::uuid))
  • Rows Removed by Filter: 130
11. 0.643 0.643 ↑ 1.0 137 1

Seq Scan on monetary_pricelistdestinations (cost=0.00..3.37 rows=137 width=9) (actual time=0.626..0.643 rows=137 loops=1)

12. 0.023 1.076 ↑ 1.0 25 1

Hash (cost=3.12..3.12 rows=25 width=20) (actual time=1.076..1.076 rows=25 loops=1)

  • Buckets: 1,024 Batches: 1 Memory Usage: 10kB
13. 0.036 1.053 ↑ 1.0 25 1

Hash Left Join (cost=1.56..3.12 rows=25 width=20) (actual time=1.040..1.053 rows=25 loops=1)

  • Hash Cond: (organization_organizationdata.organization_id = organization_organization.id)
14. 0.504 0.504 ↑ 1.0 25 1

Seq Scan on organization_organizationdata (cost=0.00..1.25 rows=25 width=8) (actual time=0.501..0.504 rows=25 loops=1)

15. 0.012 0.513 ↑ 1.0 25 1

Hash (cost=1.25..1.25 rows=25 width=20) (actual time=0.513..0.513 rows=25 loops=1)

  • Buckets: 1,024 Batches: 1 Memory Usage: 10kB
16. 0.501 0.501 ↑ 1.0 25 1

Seq Scan on organization_organization (cost=0.00..1.25 rows=25 width=20) (actual time=0.484..0.501 rows=25 loops=1)

17. 0.049 0.049 ↑ 1.0 1 7

Index Only Scan using monetary_pricelist_pkey on monetary_pricelist t5 (cost=0.14..0.31 rows=1 width=4) (actual time=0.007..0.007 rows=1 loops=7)

  • Index Cond: (id = monetary_pricelistdestinations.pricelist_id)
  • Heap Fetches: 7
18. 8.652 8.652 ↓ 2.1 3,368 7

Index Scan using monetary_drugprice_pricelist_id_1ce160ce on monetary_drugprice t4 (cost=0.42..110.21 rows=1,581 width=8) (actual time=0.010..1.236 rows=3,368 loops=7)

  • Index Cond: (pricelist_id = t5.id)
19. 212.193 212.193 ↓ 1.3 19 23,577

Index Scan using monetary_drugprice_drug_id_c2f278e5 on monetary_drugprice (cost=0.42..0.78 rows=15 width=8) (actual time=0.002..0.009 rows=19 loops=23,577)

  • Index Cond: (drug_id = t4.drug_id)
20. 0.044 0.757 ↓ 1.0 93 1

Hash (cost=6.45..6.45 rows=91 width=4) (actual time=0.757..0.757 rows=93 loops=1)

  • Buckets: 1,024 Batches: 1 Memory Usage: 12kB
21. 0.713 0.713 ↓ 1.0 93 1

Seq Scan on monetary_pricelist (cost=0.00..6.45 rows=91 width=4) (actual time=0.655..0.713 rows=93 loops=1)

  • Filter: (active AND ((NOT expires) OR (expires AND ((timezone('UTC'::text, datestart))::date <= '2019-01-22'::date) AND ((timezone('UTC'::text, dateend))::date >= '2019-01-22'::date))))
  • Rows Removed by Filter: 45
Planning time : 25.871 ms
Execution time : 3,638.544 ms