I am trying to tweak the query and this is what I got so far but it takes ages to return a result (I have around 30k tournaments in my DB).
Can someone please show me how to make this query?
Thanks.
- Code: Select all
select avg("cnt_itm")
from
(SELECT
((tourney_summary.id_tourney)) AS "cnt_tourneys",
(((CASE when(tourney_results.amt_won > 0) THEN 1 ELSE 0 END))) AS "cnt_itm"
FROM tourney_blinds,
tourney_table_type ,
tourney_summary tsttt,
tourney_hand_summary,
tourney_hand_player_statistics ,
tourney_results,
tourney_summary
WHERE (tourney_results.id_tourney = tourney_hand_player_statistics.id_tourney
AND tourney_results.id_player = tourney_hand_player_statistics.id_player)
AND (tourney_summary.id_tourney = tourney_hand_player_statistics.id_tourney)
AND (tourney_results.id_tourney = tourney_summary.id_tourney)
AND (tourney_hand_player_statistics.id_player =
(SELECT id_player
FROM player
WHERE player_name_search='my sn here'
AND id_site='100'))
AND (tourney_hand_summary.id_hand = tourney_hand_player_statistics.id_hand)
AND (tourney_blinds.id_blinds = tourney_hand_player_statistics.id_blinds)
AND (tsttt.id_tourney = tourney_hand_player_statistics.id_tourney
AND tsttt.id_table_type = tourney_table_type.id_table_type)
AND ((((((((tourney_summary.id_table_type IN
(SELECT lttt.id_table_type
FROM tourney_table_type lttt
WHERE lttt.val_seats = 2))))))
AND (((((tourney_hand_summary.id_gametype = 1))
AND ((tourney_blinds.flg_nl))))
AND ((((tourney_hand_summary.id_site IN (100))))))))
AND ((tourney_hand_summary.id_gametype IN(1))
AND (tourney_table_type.val_speed = 'S')
))
) as data