Speed up slow postgres query with indices (~5 minutes)
WHERE user_id = 1
ORDER BY game_id DESC



You probably need an index on bets (user_id, game_id).  That would let it tackle the above in a very efficient way, rather than the very inefficient it is doing it now:


"Filter": "(bets.user_id = 1)",
"Rows Removed by Filter": 106898896,



If that doesn't do it for you, please provide a complete text-formatted "explain (analyze, buffers)".  Neither of the ways you presented it is very effective.  Especially since we don't even know what tool generated the image one, and the two things seem to have come from different executions plans.