PostgreSQL query runs faster with index scan, but engine chooses hash join

后端 未结 4 1979
逝去的感伤
逝去的感伤 2020-12-08 05:35

The query:

SELECT \"replays_game\".*
FROM \"replays_game\"
INNER JOIN
 \"replays_playeringame\" ON \"replays_game\".\"id\" = \"replays_playeringame\".\"game_         


        
4条回答
  •  半阙折子戏
    2020-12-08 05:43

    You might get a better execution plan using a multiple column (player_id, game_id) index on the replays_playeringame table. This avoids having to use a random page seek to look up the game id(s) for the player id.

提交回复
热议问题