sum( If[ expression] vs sum(select case expression)

Discuss how to create custom stats, reports and HUD profiles and share your creations.

Moderators: WhiteRider, kraada, Flag_Hippo, morny, Moderators

sum( If[ expression] vs sum(select case expression)

Postby Mallaina » Tue Oct 14, 2025 5:07 am

I've written multiple custom stats for my HUD and, based on what I read in the forum, I understood that your native if[] syntax behaves similarly to select case(). So I decided to structure everything using select case() for clarity and modularity.
However, when I'm running a session, PT4 warns me that performance is slow and suggests database maintenance. Honestly, I don't mind the slight delay—refreshing takes no more than 7 seconds—but I do know I'm using a large number of custom stats.
Recently, I've started optimizing the stats to eliminate redundant conditions and simplify expressions. A friend mentioned that using the native if[] is more efficient than select case(), especially when performance matters.
Could you confirm whether if[] is indeed faster in practice, and whether it's worth refactoring my stats to use it instead of select case()? Any recommendations for improving performance without sacrificing clarity would be appreciated
Mallaina
 
Posts: 28
Joined: Sat May 12, 2012 2:45 pm

Re: sum( If[ expression] vs sum(select case expression)

Postby Flag_Hippo » Thu Oct 16, 2025 10:24 am

That isn't something I've tested so I can't comment on performance. Are your custom columns using the database cache? If they are then if you haven't already make sure to rebuild your custom cache via 'Database -> Database Management -> Rebuild Cache -> Custom Cache Rebuild'. Also open your 'postgresql.conf' file in C:\Program Files\PostgreSQL\x\data with Notepad and if PokerTracker 4 has tuned your 'max_connections' setting to a value lower than 100 then change that back to 100, save the change and restart your PostgreSQL service (you can do this via Windows services or in PokerTracker 4 via 'Database -> Database Management -> Restart Service).
Flag_Hippo
Moderator
 
Posts: 17044
Joined: Tue Jan 31, 2012 7:50 am

Re: sum( If[ expression] vs sum(select case expression)

Postby Mallaina » Fri Oct 17, 2025 6:03 am

Rebuilding the custom cache is a routine task every time I modify a custom column. However, if maxiconnections in the config was set to 20, I've now increased it to 100. Thanks.
Mallaina
 
Posts: 28
Joined: Sat May 12, 2012 2:45 pm


Return to Custom Stats, Reports and HUD Profiles

Who is online

Users browsing this forum: No registered users and 11 guests