Page 1 of 1

Order of Expressions for Statistics

PostPosted: Wed Mar 11, 2009 2:50 am
by MrBug
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?

Re: Order of Expressions for Statistics

PostPosted: Wed Mar 11, 2009 9:49 am
by kraada
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.

Re: Order of Expressions for Statistics

PostPosted: Wed Mar 11, 2009 12:28 pm
by WhiteRider
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.

Re: Order of Expressions for Statistics

PostPosted: Mon Mar 16, 2009 3:29 am
by MrBug
So, do you have a definite answer yet?

Re: Order of Expressions for Statistics

PostPosted: Mon Mar 16, 2009 11:05 am
by kraada
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.