ran it twice... first one is after rest (clean memory database takes longest)
"Aggregate (cost=818.14..818.16 rows=1 width=8) (actual time=53911.325..53911.325 rows=1 loops=1)"
" InitPlan 1 (returns $0)"
" -> Seq Scan on lookup_actions (cost=0.00..1.64 rows=1 width=4) (actual time=8.698..8.711 rows=1 loops=1)"
" Filter: (action = 'F'::text)"
" -> Nested Loop (cost=0.00..816.48 rows=1 width=8) (actual time=101.976..53898.685 rows=1720 loops=1)"
" -> Nested Loop (cost=0.00..811.40 rows=1 width=10) (actual time=85.251..53863.487 rows=1720 loops=1)"
" -> Nested Loop (cost=0.00..777.60 rows=4 width=16) (actual time=45.761..36688.459 rows=5435 loops=1)"
" -> Seq Scan on player p (cost=0.00..281.68 rows=1 width=4) (actual time=4.356..31.711 rows=1 loops=1)"
" Filter: (player_name = '*********'::text)"
" -> Index Scan using "hhpd:idx2-id_player" on holdem_hand_player_detail pd (cost=0.00..495.88 rows=4 width=12) (actual time=41.399..36652.036 rows=5435 loops=1)"
" Index Cond: (pd.id_player = p.id_player)"
" Filter: (pd.amt_p_raise_facing = 0.16)"
" -> Index Scan using holdem_hand_player_statistics_primary_key on holdem_hand_player_statistics ps (cost=0.00..8.43 rows=1 width=10) (actual time=3.156..3.157 rows=0 loops=5435)"
" Index Cond: ((ps.id_player = pd.id_player) AND (ps.id_hand = pd.id_hand))"
" Filter: (ps.flg_p_face_raise AND (ps."position" = 0))"
" -> Index Scan using holdem_limit_primary_key on holdem_limit l (cost=0.00..5.07 rows=1 width=2) (actual time=0.016..0.017 rows=1 loops=1720)"
" Index Cond: (l.id_limit = ps.id_limit)"
" Filter: (l.amt_bb = 0.04)"
"Total runtime: 53911.504 ms"
second one (optimize by postgre)
"Aggregate (cost=818.14..818.16 rows=1 width=8) (actual time=758.187..758.188 rows=1 loops=1)"
" InitPlan 1 (returns $0)"
" -> Seq Scan on lookup_actions (cost=0.00..1.64 rows=1 width=4) (actual time=0.017..0.024 rows=1 loops=1)"
" Filter: (action = 'F'::text)"
" -> Nested Loop (cost=0.00..816.48 rows=1 width=8) (actual time=0.763..756.884 rows=1720 loops=1)"
" -> Nested Loop (cost=0.00..811.40 rows=1 width=10) (actual time=0.756..749.142 rows=1720 loops=1)"
" -> Nested Loop (cost=0.00..777.60 rows=4 width=16) (actual time=0.711..632.017 rows=5435 loops=1)"
" -> Seq Scan on player p (cost=0.00..281.68 rows=1 width=4) (actual time=0.018..3.097 rows=1 loops=1)"
" Filter: (player_name = '********'::text)"
" -> Index Scan using "hhpd:idx2-id_player" on holdem_hand_player_detail pd (cost=0.00..495.88 rows=4 width=12) (actual time=0.690..627.395 rows=5435 loops=1)"
" Index Cond: (pd.id_player = p.id_player)"
" Filter: (pd.amt_p_raise_facing = 0.16)"
" -> Index Scan using holdem_hand_player_statistics_primary_key on holdem_hand_player_statistics ps (cost=0.00..8.43 rows=1 width=10) (actual time=0.020..0.020 rows=0 loops=5435)"
" Index Cond: ((ps.id_player = pd.id_player) AND (ps.id_hand = pd.id_hand))"
" Filter: (ps.flg_p_face_raise AND (ps."position" = 0))"
" -> Index Scan using holdem_limit_primary_key on holdem_limit l (cost=0.00..5.07 rows=1 width=2) (actual time=0.003..0.003 rows=1 loops=1720)"
" Index Cond: (l.id_limit = ps.id_limit)"
" Filter: (l.amt_bb = 0.04)"
"Total runtime: 758.339 ms"
first one bugs me... because changing to a different query act more like the first one