I figure i ll update my post above. The original query i posted was actually a bit mixed up.
Temporary workaround for the hang:
First, delete the 2 unique constraints and replace them with normal indices:
- Code: Select all
DROP INDEX "hhs-unique_hand_no";
DROP INDEX "thhs-unique_hand_no";
CREATE INDEX "hhs-hand_no" on holdem_hand_summary(hand_no);
CREATE INDEX "thhs-hand_no" on tourney_holdem_hand_summary(hand_no);
You only have to run above code once. This removes the hang, but PT will now import duplicate hands into the database.
To remove all duplicates from your database, run:
- Code: Select all
select hs1.id_hand into temporary table dupes
from holdem_hand_summary hs1, holdem_hand_summary hs2
where hs1.hand_no=hs2.hand_no and hs1.id_hand>hs2.id_hand;
select distinct hhps.id_session into temporary table corruptsessions
from holdem_hand_player_statistics hhps ,dupes d where hhps.id_hand=d.id_hand;
delete from holdem_hand_summary where id_hand in (select id_hand from dupes);
delete from holdem_hand_histories where id_hand in (select id_hand from dupes);
delete from holdem_hand_player_combinations where id_hand in (select id_hand from dupes);
delete from holdem_hand_player_detail where id_hand in (select id_hand from dupes);
delete from holdem_hand_player_statistics where id_hand in (select id_hand from dupes);
update holdem_table_session_summary set
cnt_hands=t.cnt_hands, cnt_hands_won=t.cnt_hands_won, cnt_ttl_players=cnt_players,
amt_pot=t.amt_pot, amt_won=t.amt_won, amt_rake=t.amt_rake, amt_mgr=t.amt_mgr
from
(
select hhps.id_session, count(*) as cnt_hands,
sum(CASE WHEN flg_won_hand=true THEN 1 ELSE 0 END) as cnt_hands_won,
sum(amt_pot) as amt_pot, sum(amt_won) as amt_won,
sum(amt_rake * (CASE WHEN flg_won_hand=true THEN 1 ELSE 0 END)) as amt_rake,
sum(amt_mgr) as amt_mgr,
sum(cnt_players) as cnt_players
from holdem_hand_player_statistics hhps, holdem_hand_summary hhs, corruptsessions cs
where hhps.id_session=cs.id_session and hhs.id_hand=hhps.id_hand group by hhps.id_session
) as t
where holdem_table_session_summary.id_session=t.id_session;
drop table corruptsessions;
drop table dupes;
You can do this whenever you think dupes have been imported (PT3 should be closed). It deletes all duplicates from the database, and updates the session-summaries, etc accordingly.