On Apr 12, 2017, at 2:00 PM,Kirk Brooks wrote: > Sum works fine on a selection of records or on an array. It used to be a > little slow but not now.
Sum and the other series commands are optimized and will use the index on field a field if it exists. Saves loading all the records in the selection into the data cache. > If you are working on 4D server it's useful to build some functions that > will run on the server to speed things up even more. Using your example you > could write: > > // Customer_get_invoiceSum (id) > QUERY([INVOICE];[INVOICE]customer=$1) > $0:=Sum([INVOICE]amount) > UNLOAD RECORD([INVOICE]) > > Set the Execute on server attribute and use it as > > $total:= Customer_get_invoiceSum(2) The series command are also optimized for 4D Server. So it will already do the Sum on 4D Server. 4D has already done the optimizations for you with the Series commands. Doing the work on 4D Server and using indexes is what makes this super fast. Tim ******************************************** Tim Nevels Innovative Solutions 785-749-3444 timnev...@mac.com ******************************************** ********************************************************************** 4D Internet Users Group (4D iNUG) FAQ: http://lists.4d.com/faqnug.html Archive: http://lists.4d.com/archives.html Options: http://lists.4d.com/mailman/options/4d_tech Unsub: mailto:4d_tech-unsubscr...@lists.4d.com **********************************************************************