explain.depesz.com

PostgreSQL's explain analyze made readable

Result: kHAV

Settings
# exclusive inclusive rows x rows loops node
1. 0.160 53.486 ↑ 1.0 21 1

Group (cost=0.14..754,310.54 rows=21 width=36) (actual time=7.389..53.486 rows=21 loops=1)

  • Group Key: loc.location_id
2. 0.049 0.049 ↑ 1.0 21 1

Index Only Scan using location_locationid_companyid_index on location loc (cost=0.14..8.58 rows=21 width=4) (actual time=0.011..0.049 rows=21 loops=1)

  • Index Cond: (company_id = 1)
  • Heap Fetches: 21
3.          

SubPlan (for Group)

4. 2.898 53.277 ↑ 1.0 1 21

Aggregate (cost=35,919.13..35,919.14 rows=1 width=32) (actual time=2.537..2.537 rows=1 loops=21)

5. 0.399 50.379 ↑ 1.1 26 21

Subquery Scan on query_discounts (cost=5.03..35,918.98 rows=29 width=125) (actual time=0.079..2.399 rows=26 loops=21)

6. 16.504 49.980 ↑ 1.1 26 21

Bitmap Heap Scan on discount dis (cost=5.03..35,918.69 rows=29 width=329) (actual time=0.076..2.380 rows=26 loops=21)

  • Recheck Cond: (location_id = loc.location_id)
  • Filter: (NOT is_deleted)
  • Rows Removed by Filter: 63
  • Heap Blocks: exact=568
7. 0.231 0.231 ↑ 1.1 89 21

Bitmap Index Scan on discount_location_id_idx1 (cost=0.00..5.03 rows=100 width=0) (actual time=0.011..0.011 rows=89 loops=21)

  • Index Cond: (location_id = loc.location_id)
8.          

SubPlan (for Bitmap Heap Scan)

9. 3.815 6.540 ↑ 1.0 1 545

Aggregate (cost=15.89..15.90 rows=1 width=32) (actual time=0.012..0.012 rows=1 loops=545)

10. 2.725 2.725 ↓ 1.4 7 545

Index Scan using discount_redeemable_days_pkey on discount_redeemable_days drd (cost=0.29..15.88 rows=5 width=5) (actual time=0.003..0.005 rows=7 loops=545)

  • Index Cond: (discount_id = dis.discount_id)
11. 0.545 13.625 ↑ 1.0 1 545

Result (cost=609.85..609.86 rows=1 width=32) (actual time=0.025..0.025 rows=1 loops=545)

12.          

Initplan (for Result)

13. 0.545 13.080 ↓ 0.0 0 545

Limit (cost=11.92..609.85 rows=1 width=32) (actual time=0.024..0.024 rows=0 loops=545)

14. 8.175 12.535 ↓ 0.0 0 545

Bitmap Heap Scan on discount_promo_code dpc (cost=11.92..609.85 rows=1 width=32) (actual time=0.023..0.023 rows=0 loops=545)

  • Recheck Cond: (discount_id = dis.discount_id)
  • Filter: (NOT single_use)
  • Rows Removed by Filter: 101
  • Heap Blocks: exact=769
15. 4.360 4.360 ↑ 4.8 101 545

Bitmap Index Scan on discount_promo_code_discount_id_idx1 (cost=0.00..11.92 rows=484 width=0) (actual time=0.008..0.008 rows=101 loops=545)

  • Index Cond: (discount_id = dis.discount_id)
16. 0.545 13.080 ↑ 1.0 1 545

Result (cost=609.85..609.86 rows=1 width=4) (actual time=0.024..0.024 rows=1 loops=545)

17.          

Initplan (for Result)

18. 0.545 12.535 ↓ 0.0 0 545

Limit (cost=11.92..609.85 rows=1 width=4) (actual time=0.023..0.023 rows=0 loops=545)

19. 9.810 11.990 ↓ 0.0 0 545

Bitmap Heap Scan on discount_promo_code dpc_1 (cost=11.92..609.85 rows=1 width=4) (actual time=0.022..0.022 rows=0 loops=545)

  • Recheck Cond: (discount_id = dis.discount_id)
  • Filter: (NOT single_use)
  • Rows Removed by Filter: 101
  • Heap Blocks: exact=769
20. 2.180 2.180 ↑ 4.8 101 545

Bitmap Index Scan on discount_promo_code_discount_id_idx1 (cost=0.00..11.92 rows=484 width=0) (actual time=0.004..0.004 rows=101 loops=545)

  • Index Cond: (discount_id = dis.discount_id)