explain.depesz.com

PostgreSQL's explain analyze made readable

Result: Wczc

Settings
# exclusive inclusive rows x rows loops node
1. 0.155 3,383.227 ↓ 1.2 14 1

Group (cost=0.14..890,444.00 rows=12 width=36) (actual time=313.707..3,383.227 rows=14 loops=1)

  • Group Key: loc.location_id
2. 0.084 0.084 ↓ 1.2 14 1

Index Scan using location_locationid_companyid_index on location loc (cost=0.14..12.58 rows=12 width=4) (actual time=0.010..0.084 rows=14 loops=1)

  • Index Cond: (company_id = 1)
  • Filter: is_open
  • Rows Removed by Filter: 7
3.          

SubPlan (for Group)

4. 6.524 3,382.988 ↑ 1.0 1 14

Aggregate (cost=74,202.61..74,202.62 rows=1 width=32) (actual time=241.641..241.642 rows=1 loops=14)

5. 1.624 3,376.464 ↓ 1.2 34 14

Subquery Scan on query_discounts (cost=0.00..74,202.46 rows=29 width=125) (actual time=6.872..241.176 rows=34 loops=14)

6. 38.840 3,374.840 ↓ 1.2 34 14

Seq Scan on discount dis (cost=0.00..74,202.17 rows=29 width=329) (actual time=6.862..241.060 rows=34 loops=14)

  • Filter: ((NOT is_deleted) AND (location_id = loc.location_id))
  • Rows Removed by Filter: 1,858
7.          

SubPlan (for Seq Scan)

8. 5.760 10.560 ↑ 1.0 1 480

Aggregate (cost=15.89..15.90 rows=1 width=32) (actual time=0.022..0.022 rows=1 loops=480)

9. 4.800 4.800 ↓ 1.4 7 480

Index Scan using discount_redeemable_days_pkey on discount_redeemable_days drd (cost=0.29..15.88 rows=5 width=5) (actual time=0.008..0.010 rows=7 loops=480)

  • Index Cond: (discount_id = dis.discount_id)
10. 0.960 1,682.400 ↑ 1.0 1 480

Result (cost=1,269.62..1,269.63 rows=1 width=32) (actual time=3.505..3.505 rows=1 loops=480)

11.          

Initplan (for Result)

12. 1.920 1,681.440 ↓ 0.0 0 480

Limit (cost=0.00..1,269.62 rows=1 width=32) (actual time=3.503..3.503 rows=0 loops=480)

13. 1,679.520 1,679.520 ↓ 0.0 0 480

Seq Scan on discount_promo_code dpc (cost=0.00..1,269.62 rows=1 width=32) (actual time=3.499..3.499 rows=0 loops=480)

  • Filter: ((NOT single_use) AND (discount_id = dis.discount_id))
  • Rows Removed by Filter: 40,060
14. 0.960 1,643.040 ↑ 1.0 1 480

Result (cost=1,269.61..1,269.62 rows=1 width=4) (actual time=3.423..3.423 rows=1 loops=480)

15.          

Initplan (for Result)

16. 1.920 1,642.080 ↓ 0.0 0 480

Limit (cost=0.00..1,269.61 rows=1 width=4) (actual time=3.421..3.421 rows=0 loops=480)

17. 1,640.160 1,640.160 ↓ 0.0 0 480

Seq Scan on discount_promo_code dpc_1 (cost=0.00..1,269.61 rows=1 width=4) (actual time=3.417..3.417 rows=0 loops=480)

  • Filter: ((NOT single_use) AND (discount_id = dis.discount_id))
  • Rows Removed by Filter: 40,060