If I run the following code in Servoy developer, I get a new line in about .5 seconds - no problem
If I run it on my local network, I get a new line in about 1-2 seconds - a little slower - but not a problem.
If I run it over my 3G phone connected to our server with no other traffic, I get a new line in 5 - 10 seconds,
If my customer runs it over their broadband connection in Singapore - connected to our server, it takes up to 40 seconds, and yesterday they were complaining about it taking ‘minutes’.
My code is this:
function new_line_using_group()
{
var sql_query = "SELECT MAX(estimate_item_id) FROM line_items WHERE line_items.sales_id = ? AND line_items.main_group = ? AND line_items.hidden_from_estimate <> 1";
var vDataSet = databaseManager.getDataSetByQuery(databaseManager.getDataSourceServerName(controller.getDataSource()), sql_query, [forms.sale_master.salesid,globals.g_main_group], 1);
var vthehighestvaluenumber = vDataSet.getValue(1,1);
if ( globals.g_main_group == 'new group' || globals.g_main_group == 'all groups' || globals.g_main_group == 'ready to invoice') {
var thePressedButton = plugins.dialogs.showErrorDialog('No group', 'Please create or choose a group before adding a line','OK');
return;
}
else {
foundset.newRecord(true);
main_group = globals.g_main_group;
sales_id = forms.sale_master.salesid;
contacts_id = forms.sale_master.contacts_id;
company_foundset_creator = globals.g_my_group
complete = 0
hidden_from_estimate = 0
if ( vthehighestvaluenumber ) {
estimate_item_id = vthehighestvaluenumber + 10;
}
else{
estimate_item_id = 10;
}
databaseManager.saveData();
}
}
SQL performance log indicates that almost nothing takes over 00:00:002 to run, and after adding 10 lines (at 6 - 10 seconds each over my 3G connection), I see that the count of the most frequently used aggregate is 131 (average time 00:00:000 in the performance log).
Therefore my solution is not slow if run locally, SQL is not slow if run remotely, nothing seems to be a problem, yet my solution runs like a dog.
I have had other performance problems with this solution (since moving from Sybase to Postgres), and am firefighting trying to address each. My customer is not very happy, and I am unable to properly deploy my solution.
Any ideas on what I’m doing wrong or how to fix would be very gratefully received…