Search Postgresql Archives

Re: How to optimize SELECT query with multiple CASE statements?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Geoff,

On Mon, Oct 31, 2016 at 4:21 PM, Geoff Winkless <pgsqladmin@xxxxxxxx> wrote:

You could break the game table apart into game and gameplayer.

That's more "normal" and fits much more nicely, IMO, and you could
then resolve the CASE by using joins between game and (twice)
gameplayer:

SELECT ...
FROM game INNER JOIN gameplayer AS myplayer ON
game.gameid=myplayer.gameid AND myplayer.uid=in_uid
INNER JOIN gameplayer AS otherplayer ON game.gameid=otherplayer.gameid
AND otherplayer.uid!=in_uid
...

Then all the other tables simply join to myplayer and otherplayer.


do you mean, instead of having player1, player2 columns in the words_games table (as in my current schema https://gist.github.com/afarber/c40b9fc5447335db7d24 ) - I should move the player stuff (uid, hand, score) to a separate table and then JOIN them?

Regards
Alex

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux