Performance Sum() vs Count()

Discussion created by briancrockett on Oct 17, 2018
Latest reply on Oct 17, 2018 by briancrockett

I've been tasked to enhance the performance of a layout with over 200 calculations most of which are unstored and contain the SUM() function.


I noticed the previous developer has used the Sum() function a lot when he wants to get a count of records in a related table. ex. Sum(child::ZK1) where ZK1 is a stored calc field which just has 1 as the expression.


Would it be a big performance difference to change the formula to Count(child::ZK1)?  It seems to me to be a few less cycles to simply count records over adding them.


I'm also think of duplicating all these calc fields with simple number fields and adding triggers to the entry fields.
I could then replace all the unstored calcs on the layout with their plain doppelgängers so that the calcs don't run when the layout is opened. The triggers would then "Set Field" to the new plain records using the hidden unstored fields causing them to recalc. 

The layout would only refresh when the user changes data on the layout or the user clicks a refresh button. Optionally the triggers would perform scripts on server to cut down network traffic.


What does the community think, any other ideas?