Created
March 25, 2026 11:34
-
-
Save adetokunbo/62ebae0338941912f8941ae5ff33cd21 to your computer and use it in GitHub Desktop.
EXPLAIN ANALYZE — computeRewardTotals (separate queries)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| EXPLAIN ANALYZE — computeRewardTotals queries | |
| Date: 2026-03-25 | |
| Setup: 10000 activity records, 100 distinct parties, round=42 | |
| ================================================================================ | |
| EXPLAIN ANALYZE — insertPartyRewards (round=42, historyId=1) | |
| ================================================================================ | |
| Insert on app_reward_party_totals (cost=0.15..8.20 rows=0 width=0) (actual time=0.057..0.057 rows=0 loops=1) | |
| -> Index Scan using uq_app_activity_party on app_activity_party_totals (cost=0.15..8.20 rows=1 width=50) (actual time=0.056..0.056 rows=0 loops=1) | |
| Index Cond: ((history_id = '1'::bigint) AND (round_number = '42'::bigint)) | |
| Filter: ((((total_app_activity_weight)::numeric(38,10) / 1000000.0) * 2.0) >= 0.5) | |
| Rows Removed by Filter: 100 | |
| Planning Time: 0.366 ms | |
| Execution Time: 0.099 ms | |
| ================================================================================ | |
| EXPLAIN ANALYZE — insertRoundRewards (round=42, historyId=1) | |
| ================================================================================ | |
| Insert on app_reward_round_totals (cost=8.24..8.26 rows=0 width=0) (actual time=0.353..0.354 rows=0 loops=1) | |
| -> Subquery Scan on "*SELECT*" (cost=8.24..8.26 rows=1 width=114) (actual time=0.139..0.142 rows=1 loops=1) | |
| -> Aggregate (cost=8.24..8.25 rows=1 width=92) (actual time=0.137..0.138 rows=1 loops=1) | |
| -> Index Scan using uq_app_activity_party on app_activity_party_totals (cost=0.15..8.17 rows=1 width=8) (actual time=0.009..0.021 rows=100 loops=1) | |
| Index Cond: ((history_id = '1'::bigint) AND (round_number = '42'::bigint)) | |
| Planning Time: 0.439 ms | |
| Execution Time: 0.410 ms | |
| ================================================================================ | |
| Summary: | |
| - Both queries use index scan on uq_app_activity_party(history_id, round_number) | |
| - No sequential scans | |
| - Sub-millisecond execution with 100 parties | |
| - insertPartyRewards: 0.099ms (all 100 parties filtered by threshold — bulk data rewards too small) | |
| - insertRoundRewards: 0.410ms (aggregate over 100 rows, insert 1 round total row) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment