Order of Expressions for Statistics

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

Order of Expressions for Statistics

Postby MrBug » Wed Mar 11, 2009 2:50 am

In generating colums for statistics, does it matter in which order the expressions are written in terms of the execution speed of the SQL query?

Example: Number of hands where money was voluntarily into the pot on the button
1) sum(if[holdem_hand_player_statistics.flg_vpip and holdem_hand_player_statistics.position = 0, 1, 0])
2) sum(if[holdem_hand_player_statistics.position = 0 and holdem_hand_player_statistics.flg_vpip, 1, 0])

Are these two exactly equivalent in execution time? Does the PT3 parser reorder things appropriately to produce an optimised SQL query? If not, in what order should these types of expressions be written?
MrBug
 
Posts: 34
Joined: Mon Feb 18, 2008 12:45 am

Re: Order of Expressions for Statistics

Postby kraada » Wed Mar 11, 2009 9:49 am

I know the queries are dynamically generated so I would expect the query is optimized at that time, but I'll ask someone who knows more about this than I do and we'll get back to you with a more definite answer.
kraada
Moderator
 
Posts: 54430
Joined: Wed Mar 05, 2008 2:32 am
Location: NY

Re: Order of Expressions for Statistics

Postby WhiteRider » Wed Mar 11, 2009 12:28 pm

My assumption would be that the expressions will be evaluated in order and as soon as one is determined to be false the rest won't be evaluated, but I don't know that for sure.
WhiteRider
Moderator
 
Posts: 54025
Joined: Sat Jan 19, 2008 7:06 pm
Location: UK

Re: Order of Expressions for Statistics

Postby MrBug » Mon Mar 16, 2009 3:29 am

So, do you have a definite answer yet?
MrBug
 
Posts: 34
Joined: Mon Feb 18, 2008 12:45 am

Re: Order of Expressions for Statistics

Postby kraada » Mon Mar 16, 2009 11:05 am

I've just had it confirmed that the order of expressions doesn't make a difference in terms of eventual query speed, sorry for the delayed confirmation.
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