Custom Stat for (total) count hands played in tournament

Forum for users that want to write their own custom queries against the PT database either via the Structured Query Language (SQL) or using the PT3 custom stats/reports interface.

Moderator: Moderators

Custom Stat for (total) count hands played in tournament

Postby andyco » Sat Nov 06, 2010 9:10 pm

i'm sure this is simply a reflection of my unfamiliarity w/ PT3 and SQL, but i've tried several times (and searched
the forum without success) to build a simple custom stat to calculate & hold the total number of hands played
for each tournament.
specifically to be held in the section holdem.tournament.tournament - single tournament data)

for a integer column (?) of the total # of hands played in each tournament.... (cnt_hands seems to be the logical name).

there's a fairly straight forward count() function to accomplish this in the holdem.tournament. tournaments section,
but i'm surely missing something simple to accomplish the same thing for each single tourney section.
i want to reference it with/in reports which use this individual tourney data.

please show the simplicity of my ignorance, before i destroy another keyboard....

thanx in advance
andyco
 
Posts: 16
Joined: Wed Sep 22, 2010 4:00 pm

Re: Custom Stat for (total) count hands played in tournament

Postby WhiteRider » Sun Nov 07, 2010 5:45 am

It can be done, but it does slow things down somewhat - if you add the stat to a report in a large database you may find that the report takes a long time to populate.

The stat is available for download from the "Get More" section, posted by me and called "Hands Stat for Tournaments report".

The column expression is this:

cnt_hands =
SELECT count(*) FROM tourney_holdem_hand_player_statistics thhs_cnthands WHERE (thhs_cnthands.id_tourney = tourney_holdem_summary.id_tourney AND thhs_cnthands.id_player_real = player_real.id_player)
WhiteRider
Moderator
 
Posts: 54025
Joined: Sat Jan 19, 2008 7:06 pm
Location: UK

Re: Custom Stat for (total) count hands played in tournament

Postby andyco » Sun Nov 07, 2010 8:58 am

thanx tons!

that is what i was looking for .... but what specifically about this stat causes such a long execution?
i'd like to understand (and avoid) incurring such a penalty with any future custom stats i may build.

thanx again.
andyco
 
Posts: 16
Joined: Wed Sep 22, 2010 4:00 pm

Re: Custom Stat for (total) count hands played in tournament

Postby WhiteRider » Sun Nov 07, 2010 9:59 am

I don't know exactly, sorry - I had help from the development team to build this. ;)

I suspect that it is because the SELECT statement is working in a different way to the normal stats, and has to check a lot of combinations of situations. Kraada may be able to explain further but he's not around today.
WhiteRider
Moderator
 
Posts: 54025
Joined: Sat Jan 19, 2008 7:06 pm
Location: UK

Re: Custom Stat for (total) count hands played in tournament

Postby kraada » Mon Nov 08, 2010 10:04 am

COUNT(*) is very slow. It's slowness is one of those things that database administrators argue about with respect to PostgreSQL (some other database systems do it better), and there are some workarounds, but for this particular purpose there isn't really a better way to do it.
kraada
Moderator
 
Posts: 54430
Joined: Wed Mar 05, 2008 2:32 am
Location: NY


Return to Custom Stats, Reports, and SQL [Read Only]

Who is online

Users browsing this forum: No registered users and 0 guests