explain.depesz.com

PostgreSQL's explain analyze made readable

Result: mdTD : Optimization for: plan #cvNn

Settings

Optimization path:

# exclusive inclusive rows x rows loops node
1. 192.814 2,149.702 ↓ 1.1 28,247 1

Sort (cost=13,402,368.80..13,402,430.62 rows=24,728 width=1,533) (actual time=2,121.828..2,149.702 rows=28,247 loops=1)

  • Sort Key: c_order.created DESC
  • Sort Method: external merge Disk: 14408kB
  • Buffers: shared hit=665963, temp read=3921 written=3921
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. 855.252 1,956.887 ↓ 1.1 28,247 1

Seq Scan on c_order (cost=7.16..13,381,257.51 rows=24,728 width=1,533) (actual time=3.584..1,956.887 rows=28,247 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: 67916
  • Buffers: shared hit=665960
5.          

SubPlan (for Seq Scan)

6. 225.976 225.976 ↓ 0.0 0 28,247

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

  • 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=114260
7. 169.482 169.482 ↑ 1.0 1 28,247

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

  • Index Cond: (c_order_id = c_order.c_order_id)
  • Buffers: shared hit=84891
8. 28.247 338.964 ↑ 1.0 1 28,247

Aggregate (cost=56.43..56.44 rows=1 width=8) (actual time=0.012..0.012 rows=1 loops=28,247)

  • Buffers: shared hit=153891
9. 55.768 310.717 ↓ 0.0 0 28,247

Hash Semi Join (cost=53.67..56.42 rows=1 width=0) (actual time=0.011..0.011 rows=0 loops=28,247)

  • Hash Cond: (c_orderline.m_product_id = ($4))
  • Buffers: shared hit=153891
10. 254.223 254.223 ↑ 1.4 5 28,247

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

  • Index Cond: (c_order_id = c_order.c_order_id)
  • Buffers: shared hit=153596
11. 0.007 0.726 ↑ 1.0 1 1

Hash (cost=53.23..53.23 rows=1 width=32) (actual time=0.726..0.726 rows=1 loops=1)

  • Buckets: 1024 Batches: 1 Memory Usage: 9kB
  • Buffers: shared hit=295
12. 0.001 0.719 ↑ 1.0 1 1

Result (cost=53.21..53.22 rows=1 width=32) (actual time=0.719..0.719 rows=1 loops=1)

  • Buffers: shared hit=295
13.          

Initplan (for Result)

14. 0.004 0.718 ↑ 1.0 1 1

Limit (cost=0.28..53.21 rows=1 width=6) (actual time=0.716..0.718 rows=1 loops=1)

  • Buffers: shared hit=295
15. 0.714 0.714 ↑ 11.0 1 1

Index Scan Backward using m_product_pkey on m_product (cost=0.28..582.51 rows=11 width=6) (actual time=0.714..0.714 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: 627
  • Buffers: shared hit=295
16. 0.000 197.729 ↑ 1.0 1 28,247

Aggregate (cost=475.06..475.07 rows=1 width=8) (actual time=0.007..0.007 rows=1 loops=28,247)

  • Buffers: shared hit=153926
17. 82.377 197.729 ↓ 0.0 0 28,247

Hash Semi Join (cost=472.30..475.05 rows=1 width=0) (actual time=0.007..0.007 rows=0 loops=28,247)

  • Hash Cond: (c_orderline_1.m_product_id = (max(m_product_1.m_product_id)))
  • Buffers: shared hit=153926
18. 112.988 112.988 ↑ 1.4 5 28,247

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,247)

  • Index Cond: (c_order_id = c_order.c_order_id)
  • Buffers: shared hit=153596
19. 0.009 2.364 ↑ 1.0 1 1

Hash (cost=471.86..471.86 rows=1 width=32) (actual time=2.363..2.364 rows=1 loops=1)

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

Aggregate (cost=471.84..471.85 rows=1 width=32) (actual time=2.355..2.355 rows=1 loops=1)

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

Seq Scan on m_product m_product_1 (cost=0.00..471.84 rows=1 width=6) (actual time=0.294..2.342 rows=1 loops=1)

  • Filter: ((lower((description)::text) ~~ '%bolsa%'::text) AND (lower((description)::text) ~~ '%descuento%'::text))
  • Rows Removed by Filter: 7091
  • Buffers: shared hit=330
22. 0.000 169.482 ↑ 1.0 1 28,247

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

  • Buffers: shared hit=153596
23. 169.482 169.482 ↓ 0.0 0 28,247

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

  • 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=153596
24. 0.002 0.002 ↓ 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.002..0.002 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 : 4.645 ms
Execution time : 2,155.331 ms