explain.depesz.com

PostgreSQL's explain analyze made readable

Result: JfoK

Settings
# exclusive inclusive rows x rows loops node
1. 849.591 7,282.842 ↓ 337,094.0 337,094 1

Sort (cost=17,318.12..17,318.12 rows=1 width=457) (actual time=7,183.155..7,282.842 rows=337,094 loops=1)

  • Sort Key: deal.id
  • Sort Method: external merge Disk: 56704kB
2. 218.129 6,433.251 ↓ 337,094.0 337,094 1

Nested Loop Left Join (cost=328.94..17,318.11 rows=1 width=457) (actual time=96.010..6,433.251 rows=337,094 loops=1)

3. 235.424 5,540.934 ↓ 337,094.0 337,094 1

Nested Loop Left Join (cost=328.67..17,317.81 rows=1 width=389) (actual time=95.995..5,540.934 rows=337,094 loops=1)

4. 44.729 4,968.416 ↓ 337,094.0 337,094 1

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

5. 91.734 4,249.499 ↓ 337,094.0 337,094 1

Nested Loop Left Join (cost=328.25..17,317.36 rows=1 width=376) (actual time=95.978..4,249.499 rows=337,094 loops=1)

6. 404.356 3,146.483 ↓ 337,094.0 337,094 1

Nested Loop (cost=327.97..17,317.05 rows=1 width=333) (actual time=95.966..3,146.483 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. 53.169 1,311.043 ↓ 1,436.8 119,257 1

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

8. 448.937 542.332 ↓ 1,436.8 119,257 1

Bitmap Heap Scan on deal (cost=327.11..16,007.67 rows=83 width=64) (actual time=95.877..542.332 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 93.395 ↓ 0.0 0 1

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

10. 82.384 82.384 ↓ 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=82.384..82.384 rows=1,015,558 loops=1)

  • Index Cond: (type = 'CUSTOMER'::text)
11. 4.114 4.114 ↓ 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=4.114..4.114 rows=46,868 loops=1)

  • Index Cond: (receiver_office_id = 8)
12. 6.895 6.895 ↓ 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.895..6.895 rows=108,742 loops=1)

  • Index Cond: (sender_office_id = 8)
13. 715.542 715.542 ↑ 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.006..0.006 rows=1 loops=119,257)

  • Index Cond: (deal_id = deal.id)
14. 1,431.084 1,431.084 ↑ 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.008..0.012 rows=4 loops=119,257)

  • Index Cond: ((deal_id = deal_state.deal_id) AND (product_article_type = ANY ('{PRODUCT,CURRENCY}'::text[])))
15. 1,011.282 1,011.282 ↑ 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.003..0.003 rows=1 loops=337,094)

  • Index Cond: ((product_article_code = deal_row.code) AND (language = 'et'::bpchar))
16. 674.188 674.188 ↓ 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.002..0.002 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