calculation execution and relation performance

I’m analysing the performance of a solution and figure out that a simple calculation takes an total execution time of 5 seconds (!) while showing a form.
The calculation “cal_result_x” is on the table “order” and looks like

return quantity_x - order_to_order_items.sum_quantity_x

My question is why does Servoy execute the calculation 10 times on showing the form and not only one time?
Because of the relation in the calculation the average execution time is 500 ms. I think this is high enough but 10 times of 500 ms is 5 seconds!

I have replaced the calculation by a method. The execution of the function takes 200 ms and will be executed only one time. This is really a significant advantage!

which servoy version are we talking about here
What kidn of form do you show? recordview? tableview?

Hi Johan,

I’m on Servoy 6.0.4 and the form is in recordview.

Sorry for the missing info.

then i have no idea why that is triggered 10 times for you, it should only do it once,
Somehow it does find that the input is constantly changing and is i guess flagging the calc to be executed again
(if it really calculates for the same record and not for 10 different records)

Maybe you should try to create a case with that as a sample

I also have dedected the issue when running only this two codelines as onAction for a button:

databaseManager.hasRecords(auftrag_to_tp_auftrag__uid_auftrag);
application.output('true');

This is what I get on the servoy-admin Performance Statistics (I have cleared the statistics before!):

As I understand is the Relation and the Aggregate SQL executed 10 times by fireing the function only once!?
I’m wondering why?

Server Information
Servoy version 6.0.4 -build 1227
JVM Information
java.vm.name=Java HotSpot™ Client VM
java.version=1.6.0_29
PostgreSQL 9.1.2

thats just our special combined query to get also the data for the sibling records so that the next time if you would go to the next record nothing has to be get from the database anymore, we do max 10 at once

So that doesn’t mean that the calculation is executed 10 times, if you add an application output to the calc itself, is it really executed 10 times for exactly the same record (if you print the pk of that record)