explain.depesz.com

PostgreSQL's explain analyze made readable

Result: UtgT

Settings
# exclusive inclusive rows x rows loops node
1. 0.000 0.000 ↓ 0.0

Unique (cost=22,368.36..22,368.36 rows=1 width=144) (actual rows= loops=)

2. 0.000 0.000 ↓ 0.0

Sort (cost=22,368.36..22,368.36 rows=1 width=144) (actual rows= loops=)

  • Sort Key: daily_timestamp_activity.user_id
3. 0.000 0.000 ↓ 0.0

Unique (cost=22,368.30..22,368.34 rows=1 width=144) (actual rows= loops=)

4. 0.000 0.000 ↓ 0.0

Sort (cost=22,368.30..22,368.31 rows=1 width=144) (actual rows= loops=)

  • Sort Key: daily_timestamp_activity.id, daily_timestamp_activity.user_id, (get_rewards_cap_for_user(daily_timestamp_activity.user_id)), accounts.id, accounts.network_id, accounts.realm_num, accounts.shard_num, accounts.account_num, (get_rewards_total_for_account(accounts.id)), (CASE WHEN ((NOT ((alternatives: SubPlan 3 or hashed SubPlan 4))) AND ((alternatives: SubPlan 1 or hashed SubPlan 2))) THEN 'h18'::text ELSE NULL::text END), (CASE WHEN ((NOT ((alternatives: SubPlan 3 or hashed SubPlan 4))) AND ((alternatives: SubPlan 1 or hashed SubPlan 2))) THEN '100000000000'::bigint ELSE '500000000'::bigint END)
5. 0.000 0.000 ↓ 0.0

Nested Loop (cost=0.97..22,368.29 rows=1 width=144) (actual rows= loops=)

  • Join Filter: (((get_rewards_total_for_account(accounts.id)) < (get_rewards_cap_for_user(daily_timestamp_activity.user_id))) AND (daily_timestamp_activity.user_id = accounts.user_id))
6. 0.000 0.000 ↓ 0.0

Nested Loop (cost=0.41..16,503.19 rows=1 width=96) (actual rows= loops=)

7. 0.000 0.000 ↓ 0.0

Seq Scan on daily_timestamp_activity (cost=0.00..16,500.51 rows=1 width=32) (actual rows= loops=)

  • Filter: (transaction_id IS NULL)
8. 0.000 0.000 ↓ 0.0

Index Scan using users_pkey on users (cost=0.41..2.43 rows=1 width=16) (actual rows= loops=)

  • Index Cond: (id = daily_timestamp_activity.user_id)
  • Filter: is_active
9. 0.000 0.000 ↓ 0.0

Nested Loop (cost=0.55..5,864.37 rows=29 width=124) (actual rows= loops=)

10. 0.000 0.000 ↓ 0.0

Index Scan using is_network__is_test on networks n (cost=0.27..2.29 rows=1 width=16) (actual rows= loops=)

  • Index Cond: (is_test = false)
  • Filter: (NOT is_test)
11. 0.000 0.000 ↓ 0.0

Index Scan using ix_accounts__network_id on accounts (cost=0.28..25.38 rows=96 width=72) (actual rows= loops=)

  • Index Cond: (network_id = n.id)
12.          

SubPlan (forNested Loop)

13. 0.000 0.000 ↓ 0.0

Nested Loop (cost=0.56..4.82 rows=1 width=0) (actual rows= loops=)

14. 0.000 0.000 ↓ 0.0

Index Only Scan using promo_code_claims_user_id_promo_code_id_key on promo_code_claims pcc (cost=0.28..2.29 rows=1 width=16) (actual rows= loops=)

  • Index Cond: (user_id = accounts.user_id)
15. 0.000 0.000 ↓ 0.0

Index Scan using promo_codes_pkey on promo_codes pc (cost=0.28..2.30 rows=1 width=16) (actual rows= loops=)

  • Index Cond: (id = pcc.promo_code_id)
  • Filter: (network_id = accounts.network_id)
16. 0.000 0.000 ↓ 0.0

Hash Join (cost=184.33..222.14 rows=1,015 width=32) (actual rows= loops=)

  • Hash Cond: (pcc_1.promo_code_id = pc_1.id)
17. 0.000 0.000 ↓ 0.0

Seq Scan on promo_code_claims pcc_1 (cost=0.00..35.15 rows=1,015 width=32) (actual rows= loops=)

18. 0.000 0.000 ↓ 0.0

Hash (cost=142.48..142.48 rows=3,348 width=32) (actual rows= loops=)

19. 0.000 0.000 ↓ 0.0

Seq Scan on promo_codes pc_1 (cost=0.00..142.48 rows=3,348 width=32) (actual rows= loops=)

20. 0.000 0.000 ↓ 0.0

Index Scan using ix_transactions__account_id on transactions tx (cost=0.42..196.17 rows=1 width=0) (actual rows= loops=)

  • Index Cond: (account_id = accounts.id)
  • Filter: (kind ~~ 'h18'::text)
21. 0.000 0.000 ↓ 0.0

Seq Scan on transactions tx_1 (cost=0.00..16,758.17 rows=146 width=16) (actual rows= loops=)

  • Filter: (kind ~~ 'h18'::text)