explain.depesz.com

PostgreSQL's explain analyze made readable

Result: OSY9 : Optimization for: plan #YItN

Settings

Optimization path:

Optimization(s) for this plan:

# exclusive inclusive rows x rows loops node
1. 160.877 1,796.428 ↓ 1.1 28,477 1

Sort (cost=13,441,647.85..13,441,709.82 rows=24,789 width=1,533) (actual time=1,771.489..1,796.428 rows=28,477 loops=1)

  • Sort Key: c_order.created DESC
  • Sort Method: external merge Disk: 14528kB
  • Buffers: shared hit=670881, temp read=3936 written=3936
2.          

Initplan (for Sort)

3. 0.001 0.001 ↑ 1.0 1 1

Result (cost=0.00..0.01 rows=1 width=32) (actual time=0.001..0.001 rows=1 loops=1)

4. 724.285 1,635.550 ↓ 1.1 28,477 1

Seq Scan on c_order (cost=7.16..13,420,482.46 rows=24,789 width=1,533) (actual time=1.570..1,635.550 rows=28,477 loops=1)

  • Filter: ((ad_client_id = ANY ('{0,2000006}'::numeric[])) AND ((c_order_id IS NULL) OR (NOT (hashed SubPlan 8))) AND (issotrx = 'Y'::bpchar) AND ((processed = 'N'::bpchar) OR (updated > (now() - '1'::numeric))))
  • Rows Removed by Filter: 68017
  • Buffers: shared hit=670881
5.          

SubPlan (for Seq Scan)

6. 170.862 170.862 ↓ 0.0 0 28,477

Index Scan using c_bpartner_pkey on c_bpartner (cost=0.41..2.64 rows=1 width=32) (actual time=0.006..0.006 rows=0 loops=28,477)

  • Index Cond: (c_bpartner_id = c_order.c_bpartner_id)
  • Filter: (created > (('now'::cstring)::date - '2 mons'::interval))
  • Rows Removed by Filter: 1
  • Buffers: shared hit=115187
7. 142.385 142.385 ↑ 1.0 1 28,477

Index Scan using c_order_pkey on c_order co (cost=0.29..2.52 rows=1 width=32) (actual time=0.005..0.005 rows=1 loops=28,477)

  • Index Cond: (c_order_id = c_order.c_order_id)
  • Buffers: shared hit=85581
8. 28.477 256.293 ↑ 1.0 1 28,477

Aggregate (cost=56.45..56.46 rows=1 width=8) (actual time=0.009..0.009 rows=1 loops=28,477)

  • Buffers: shared hit=155007
9. 56.680 227.816 ↓ 0.0 0 28,477

Hash Semi Join (cost=53.69..56.45 rows=1 width=0) (actual time=0.008..0.008 rows=0 loops=28,477)

  • Hash Cond: (c_orderline.m_product_id = ($4))
  • Buffers: shared hit=155007
10. 170.862 170.862 ↑ 1.4 5 28,477

Index Scan using c_orderline_order on c_orderline (cost=0.42..3.16 rows=7 width=6) (actual time=0.004..0.006 rows=5 loops=28,477)

  • Index Cond: (c_order_id = c_order.c_order_id)
  • Buffers: shared hit=154711
11. 0.006 0.274 ↑ 1.0 1 1

Hash (cost=53.26..53.26 rows=1 width=32) (actual time=0.274..0.274 rows=1 loops=1)

  • Buckets: 1024 Batches: 1 Memory Usage: 9kB
  • Buffers: shared hit=296
12. 0.002 0.268 ↑ 1.0 1 1

Result (cost=53.24..53.25 rows=1 width=32) (actual time=0.268..0.268 rows=1 loops=1)

  • Buffers: shared hit=296
13.          

Initplan (for Result)

14. 0.001 0.266 ↑ 1.0 1 1

Limit (cost=0.28..53.24 rows=1 width=6) (actual time=0.266..0.266 rows=1 loops=1)

  • Buffers: shared hit=296
15. 0.265 0.265 ↑ 11.0 1 1

Index Scan Backward using m_product_pkey on m_product (cost=0.28..582.81 rows=11 width=6) (actual time=0.265..0.265 rows=1 loops=1)

  • Index Cond: (m_product_id IS NOT NULL)
  • Filter: ((lower((description)::text) ~~ '%bolsa%'::text) AND (lower((description)::text) !~~ '%descuento%'::text))
  • Rows Removed by Filter: 638
  • Buffers: shared hit=296
16. 0.000 170.862 ↑ 1.0 1 28,477

Aggregate (cost=475.28..475.29 rows=1 width=8) (actual time=0.006..0.006 rows=1 loops=28,477)

  • Buffers: shared hit=155041
17. 55.896 170.862 ↓ 0.0 0 28,477

Hash Semi Join (cost=472.52..475.27 rows=1 width=0) (actual time=0.006..0.006 rows=0 loops=28,477)

  • Hash Cond: (c_orderline_1.m_product_id = (max(m_product_1.m_product_id)))
  • Buffers: shared hit=155041
18. 113.908 113.908 ↑ 1.4 5 28,477

Index Scan using c_orderline_order on c_orderline c_orderline_1 (cost=0.42..3.16 rows=7 width=6) (actual time=0.003..0.004 rows=5 loops=28,477)

  • Index Cond: (c_order_id = c_order.c_order_id)
  • Buffers: shared hit=154711
19. 0.005 1.058 ↑ 1.0 1 1

Hash (cost=472.08..472.08 rows=1 width=32) (actual time=1.058..1.058 rows=1 loops=1)

  • Buckets: 1024 Batches: 1 Memory Usage: 9kB
  • Buffers: shared hit=330
20. 0.014 1.053 ↑ 1.0 1 1

Aggregate (cost=472.06..472.07 rows=1 width=32) (actual time=1.053..1.053 rows=1 loops=1)

  • Buffers: shared hit=330
21. 1.039 1.039 ↑ 1.0 1 1

Seq Scan on m_product m_product_1 (cost=0.00..472.06 rows=1 width=6) (actual time=0.130..1.039 rows=1 loops=1)

  • Filter: ((lower((description)::text) ~~ '%bolsa%'::text) AND (lower((description)::text) ~~ '%descuento%'::text))
  • Rows Removed by Filter: 7102
  • Buffers: shared hit=330
22. 28.477 170.862 ↑ 1.0 1 28,477

Aggregate (cost=3.18..3.19 rows=1 width=8) (actual time=0.006..0.006 rows=1 loops=28,477)

  • Buffers: shared hit=154711
23. 142.385 142.385 ↓ 0.0 0 28,477

Index Scan using c_orderline_order on c_orderline c_orderline_2 (cost=0.42..3.18 rows=1 width=0) (actual time=0.005..0.005 rows=0 loops=28,477)

  • Index Cond: (c_order_id = c_order.c_order_id)
  • Filter: (m_product_id = ANY ('{2020603,2020712}'::numeric[]))
  • Rows Removed by Filter: 5
  • Buffers: shared hit=154711
24. 0.001 0.001 ↓ 0.0 0 1

Index Scan using ad_private_access_pkey on ad_private_access (cost=0.15..7.15 rows=1 width=16) (actual time=0.001..0.001 rows=0 loops=1)

  • Index Cond: (ad_table_id = '259'::numeric)
  • Filter: ((ad_user_id <> '100'::numeric) AND (isactive = 'Y'::bpchar))
  • Buffers: shared hit=1
Planning time : 3.109 ms
Execution time : 1,801.222 ms