explain.depesz.com

PostgreSQL's explain analyze made readable

Result: 1U1V

Settings

Optimization(s) for this plan:

# exclusive inclusive rows x rows loops node
1. 0.009 160.437 ↑ 1.0 1 1

Aggregate (cost=64,739.47..64,739.48 rows=1 width=96) (actual time=160.437..160.437 rows=1 loops=1)

2. 0.009 160.428 ↑ 1.2 4 1

HashAggregate (cost=64,739.33..64,739.38 rows=5 width=96) (actual time=160.427..160.428 rows=4 loops=1)

  • Group Key: "*SELECT* 1".target_amount, ((0)::numeric), (((0))::numeric)
3. 0.002 160.419 ↑ 1.2 4 1

Append (cost=21.55..64,739.29 rows=5 width=96) (actual time=0.056..160.419 rows=4 loops=1)

4. 0.006 0.056 ↑ 1.3 3 1

HashAggregate (cost=21.55..21.60 rows=4 width=96) (actual time=0.055..0.056 rows=3 loops=1)

  • Group Key: "*SELECT* 1".target_amount, ((0)::numeric), (0)
5. 0.001 0.050 ↑ 1.3 3 1

Append (cost=4.30..21.52 rows=4 width=68) (actual time=0.039..0.050 rows=3 loops=1)

6. 0.002 0.043 ↑ 1.5 2 1

Subquery Scan on *SELECT* 1 (cost=4.30..13.32 rows=3 width=39) (actual time=0.039..0.043 rows=2 loops=1)

7. 0.016 0.041 ↑ 1.5 2 1

Bitmap Heap Scan on salesman_sales_target sst (cost=4.30..13.28 rows=3 width=11) (actual time=0.037..0.041 rows=2 loops=1)

  • Recheck Cond: (salesman_id = 620)
  • Heap Blocks: exact=2
8. 0.025 0.025 ↑ 1.5 2 1

Bitmap Index Scan on salesman_idx_salesman_sales_target (cost=0.00..4.30 rows=3 width=0) (actual time=0.025..0.025 rows=2 loops=1)

  • Index Cond: (salesman_id = 620)
9. 0.001 0.006 ↑ 1.0 1 1

Subquery Scan on *SELECT* 2 (cost=8.18..8.21 rows=1 width=68) (actual time=0.006..0.006 rows=1 loops=1)

10. 0.002 0.005 ↑ 1.0 1 1

Aggregate (cost=8.18..8.19 rows=1 width=40) (actual time=0.005..0.005 rows=1 loops=1)

11. 0.003 0.003 ↓ 0.0 0 1

Index Scan using salesman_idx_invoice on invoice i (cost=0.14..8.17 rows=1 width=138) (actual time=0.003..0.003 rows=0 loops=1)

  • Index Cond: (salesman_id = 620)
  • Filter: (enabled AND (NOT is_deleted) AND ((billing_type)::text = ANY ('{SELLING,SELLING_RETURN}'::text[])) AND (date_part('month'::text, date) = date_part('month'::text, (now() - '5 days'::interval))))
12. 0.002 160.361 ↑ 1.0 1 1

Subquery Scan on *SELECT* 3 (cost=64,717.66..64,717.69 rows=1 width=96) (actual time=160.361..160.361 rows=1 loops=1)

13. 0.021 160.359 ↑ 1.0 1 1

Aggregate (cost=64,717.66..64,717.67 rows=1 width=40) (actual time=160.359..160.359 rows=1 loops=1)

14. 11.795 160.338 ↑ 1.8 4 1

Hash Join (cost=3,602.52..64,717.61 rows=7 width=60) (actual time=153.301..160.338 rows=4 loops=1)

  • Hash Cond: (od.orders_id = o.id)
15. 139.998 148.501 ↑ 4.3 121,378 1

Bitmap Heap Scan on order_detail od (cost=2,085.58..61,832.79 rows=521,081 width=68) (actual time=11.477..148.501 rows=121,378 loops=1)

  • Recheck Cond: ((quantity - shipped_amount) > '0'::numeric)
  • Heap Blocks: exact=16370
16. 8.503 8.503 ↑ 4.3 121,378 1

Bitmap Index Scan on order_detail_idx_where (cost=0.00..1,955.31 rows=521,081 width=0) (actual time=8.503..8.503 rows=121,378 loops=1)

17. 0.002 0.042 ↑ 1.0 2 1

Hash (cost=1,516.92..1,516.92 rows=2 width=8) (actual time=0.042..0.042 rows=2 loops=1)

  • Buckets: 1024 Batches: 1 Memory Usage: 9kB
18. 0.015 0.040 ↑ 1.0 2 1

Bitmap Heap Scan on orders o (cost=11.76..1,516.92 rows=2 width=8) (actual time=0.037..0.040 rows=2 loops=1)

  • Recheck Cond: (salesman_id = 620)
  • Filter: (enabled AND (NOT is_deleted) AND (NOT cancelled) AND (date_part('month'::text, (order_date)::timestamp without time zone) = date_part('month'::text, now())))
  • Heap Blocks: exact=2
19. 0.025 0.025 ↑ 222.5 2 1

Bitmap Index Scan on salesman_idx (cost=0.00..11.76 rows=445 width=0) (actual time=0.024..0.025 rows=2 loops=1)

  • Index Cond: (salesman_id = 620)
Planning time : 0.716 ms
Execution time : 160.584 ms