explain.depesz.com

PostgreSQL's explain analyze made readable

Result: o1HQ

Settings
# exclusive inclusive rows x rows loops node
1. 0.035 7.942 ↑ 1.0 1 1

Result (cost=28,817.32..28,817.33 rows=1 width=32) (actual time=7.942..7.942 rows=1 loops=1)

2.          

CTE activemerchants

3. 6.058 6.058 ↑ 23.8 335 1

Seq Scan on merchants (cost=0.00..3,328.23 rows=7,983 width=32) (actual time=0.010..6.058 rows=335 loops=1)

  • Filter: (active_offer IS NOT NULL)
  • Rows Removed by Filter: 7,688
4.          

CTE activeoffers

5. 0.123 1.268 ↑ 103.9 334 1

Nested Loop (cost=180.04..689.72 rows=34,694 width=32) (actual time=0.126..1.268 rows=334 loops=1)

6. 0.106 0.140 ↓ 1.7 335 1

HashAggregate (cost=179.62..181.62 rows=200 width=16) (actual time=0.103..0.140 rows=335 loops=1)

  • Group Key: activemerchants.active_offer
7. 0.034 0.034 ↑ 23.8 335 1

CTE Scan on activemerchants (cost=0.00..159.66 rows=7,983 width=16) (actual time=0.000..0.034 rows=335 loops=1)

8. 1.005 1.005 ↑ 1.0 1 335

Index Scan using offers_pkey on offers (cost=0.42..2.54 rows=1 width=32) (actual time=0.003..0.003 rows=1 loops=335)

  • Index Cond: (offer_id = activemerchants.active_offer)
  • Filter: (status = 'ON'::offer_status)
  • Rows Removed by Filter: 0
9.          

Initplan (for Result)

10. 0.119 7.907 ↑ 4,146.1 334 1

Merge Join (cost=3,987.29..24,799.37 rows=1,384,811 width=16) (actual time=7.748..7.907 rows=334 loops=1)

  • Merge Cond: (activemerchants_1.merchant_id = activeoffers.offering_merchant_id)
11. 0.121 6.301 ↑ 23.8 335 1

Sort (cost=677.07..697.02 rows=7,983 width=16) (actual time=6.277..6.301 rows=335 loops=1)

  • Sort Key: activemerchants_1.merchant_id
  • Sort Method: quicksort Memory: 40kB
12. 6.180 6.180 ↑ 23.8 335 1

CTE Scan on activemerchants activemerchants_1 (cost=0.00..159.66 rows=7,983 width=16) (actual time=0.012..6.180 rows=335 loops=1)

13. 0.102 1.487 ↑ 103.9 334 1

Sort (cost=3,310.22..3,396.96 rows=34,694 width=16) (actual time=1.468..1.487 rows=334 loops=1)

  • Sort Key: activeoffers.offering_merchant_id
  • Sort Method: quicksort Memory: 40kB
14. 1.385 1.385 ↑ 103.9 334 1

CTE Scan on activeoffers (cost=0.00..693.88 rows=34,694 width=16) (actual time=0.127..1.385 rows=334 loops=1)

Planning time : 0.262 ms
Execution time : 7.986 ms