explain.depesz.com

PostgreSQL's explain analyze made readable

Result: 1DcF

Settings
# exclusive inclusive rows x rows loops node
1. 563.246 6,077.589 ↓ 337,094.0 337,094 1

Sort (cost=17,318.12..17,318.12 rows=1 width=457) (actual time=5,991.895..6,077.589 rows=337,094 loops=1)

  • Sort Key: deal.created DESC
  • Sort Method: external merge Disk: 56696kB
2. 74.677 5,514.343 ↓ 337,094.0 337,094 1

Nested Loop Left Join (cost=328.94..17,318.11 rows=1 width=457) (actual time=103.983..5,514.343 rows=337,094 loops=1)

3. 140.777 4,765.478 ↓ 337,094.0 337,094 1

Nested Loop Left Join (cost=328.67..17,317.81 rows=1 width=389) (actual time=103.970..4,765.478 rows=337,094 loops=1)

4. 269.905 4,287.607 ↓ 337,094.0 337,094 1

Nested Loop Left Join (cost=328.53..17,317.65 rows=1 width=385) (actual time=103.956..4,287.607 rows=337,094 loops=1)

5. 257.559 3,680.608 ↓ 337,094.0 337,094 1

Nested Loop Left Join (cost=328.25..17,317.36 rows=1 width=376) (actual time=103.948..3,680.608 rows=337,094 loops=1)

6. 394.127 2,748.861 ↓ 337,094.0 337,094 1

Nested Loop (cost=327.97..17,317.05 rows=1 width=333) (actual time=103.937..2,748.861 rows=337,094 loops=1)

  • Join Filter: ((deal.type = 'CUSTOMER'::text) OR ((deal_row.quantity > '0'::numeric) AND (deal.receiver_office_id = 8)) OR ((deal_row.quantity <= '0'::numeric) AND (deal.sender_office_id = 8)))
  • Rows Removed by Join Filter: 133507
7. 87.734 1,162.164 ↓ 1,436.8 119,257 1

Nested Loop (cost=327.54..16,704.60 rows=83 width=101) (actual time=103.850..1,162.164 rows=119,257 loops=1)

8. 376.580 478.145 ↓ 1,436.8 119,257 1

Bitmap Heap Scan on deal (cost=327.11..16,007.67 rows=83 width=64) (actual time=103.795..478.145 rows=119,257 loops=1)

  • Recheck Cond: ((type = 'CUSTOMER'::text) OR (receiver_office_id = 8) OR (sender_office_id = 8))
  • Filter: ((office_id = 8) OR ((type = ANY ('{AGENT_OFFICE,CUSTOMER,CORRECTION}'::text[])) AND ((sender_office_id = 8) OR (receiver_office_id = 8))))
  • Rows Removed by Filter: 933525
  • Heap Blocks: exact=14537
9. 0.002 101.565 ↓ 0.0 0 1

BitmapOr (cost=327.11..327.11 rows=16,235 width=0) (actual time=101.565..101.565 rows=0 loops=1)

10. 91.898 91.898 ↓ 187.6 1,015,558 1

Bitmap Index Scan on deal_type_index (cost=0.00..125.02 rows=5,412 width=0) (actual time=91.898..91.898 rows=1,015,558 loops=1)

  • Index Cond: (type = 'CUSTOMER'::text)
11. 3.380 3.380 ↓ 8.7 46,868 1

Bitmap Index Scan on deal_receiver_office_id_ndx (cost=0.00..101.02 rows=5,412 width=0) (actual time=3.380..3.380 rows=46,868 loops=1)

  • Index Cond: (receiver_office_id = 8)
12. 6.285 6.285 ↓ 20.1 108,742 1

Bitmap Index Scan on deal_sender_office_id_ndx (cost=0.00..101.02 rows=5,412 width=0) (actual time=6.285..6.285 rows=108,742 loops=1)

  • Index Cond: (sender_office_id = 8)
13. 596.285 596.285 ↑ 1.0 1 119,257

Index Scan using deal_state_pkey on deal_state (cost=0.43..8.40 rows=1 width=37) (actual time=0.005..0.005 rows=1 loops=119,257)

  • Index Cond: (deal_id = deal.id)
14. 1,192.570 1,192.570 ↑ 37.0 4 119,257

Index Scan using deal_row_deal_id_product_article_type_quantity_index on deal_row (cost=0.43..4.05 rows=148 width=240) (actual time=0.007..0.010 rows=4 loops=119,257)

  • Index Cond: ((deal_id = deal_state.deal_id) AND (product_article_type = ANY ('{PRODUCT,CURRENCY}'::text[])))
15. 674.188 674.188 ↑ 1.0 1 337,094

Index Scan using product_article_translations_product_article_code_language_pk on product_article_translations (cost=0.28..0.31 rows=1 width=52) (actual time=0.002..0.002 rows=1 loops=337,094)

  • Index Cond: ((product_article_code = deal_row.code) AND (language = 'et'::bpchar))
16. 337.094 337.094 ↓ 0.0 0 337,094

Index Scan using product_product_article_code_pk on product (cost=0.27..0.29 rows=1 width=19) (actual time=0.001..0.001 rows=0 loops=337,094)

  • Index Cond: (product_article_code = deal_row.code)
17. 337.094 337.094 ↑ 1.0 1 337,094

Index Scan using currency_product_article_code_pk on currency (cost=0.14..0.16 rows=1 width=8) (actual time=0.001..0.001 rows=1 loops=337,094)

  • Index Cond: (product_article_code = deal_row.code)
18. 674.188 674.188 ↑ 1.0 1 337,094

Index Only Scan using product_article_code_pk on product_article (cost=0.28..0.29 rows=1 width=9) (actual time=0.002..0.002 rows=1 loops=337,094)

  • Index Cond: (code = deal_row.code)
  • Heap Fetches: 337084