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

Поиск
Список
Период
Сортировка
От Alexander Farber
Тема Re: How to optimize SELECT query with multiple CASE statements?
Дата
Msg-id CAADeyWjnHtbpajxy6wcfJt2-3yifF2JmZcShvJg5ucZmktUF_w@mail.gmail.com
обсуждение исходный текст
Ответ на Re: How to optimize SELECT query with multiple CASE statements?  (Geoff Winkless <pgsqladmin@geoff.dj>)
Ответы Re: How to optimize SELECT query with multiple CASE statements?  (Geoff Winkless <pgsqladmin@geoff.dj>)
Список pgsql-general
Hi Geoff,

On Mon, Oct 31, 2016 at 4:21 PM, Geoff Winkless <pgsqladmin@geoff.dj> 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

В списке pgsql-general по дате отправления:

Предыдущее
От: Alban Hertroys
Дата:
Сообщение: Re: initdb createuser commands
Следующее
От: Joshua Kehn
Дата:
Сообщение: Validity of using the test_decoding plugin for production?