explain.depesz.com

PostgreSQL's explain analyze made readable

Result: VFk2

Settings
# exclusive inclusive rows x rows loops node
1. 0.049 7.540 ↑ 1.0 1 1

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

2.          

CTE activemerchants

3. 5.481 5.481 ↑ 23.8 335 1

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

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

CTE activeoffers

5. 0.172 1.337 ↑ 103.9 334 1

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

6. 0.128 0.160 ↓ 1.7 335 1

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

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

CTE Scan on activemerchants (cost=0.00..159.66 rows=7,983 width=16) (actual time=0.001..0.032 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.132 7.491 ↑ 4,146.1 334 1

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

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

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

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

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

13. 0.130 1.587 ↑ 103.9 334 1

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

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

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

Planning time : 0.250 ms
Execution time : 7.584 ms