ROCLASI:
Do the tables of the website have a lot of indexes other than the obvious PK’s and maybe some FK’s ?
Inserts/updates on such a table can be costly because it has to update the indexes on every insert/update. Ofcourse you would only notice this with a LOT of data.
I have indexed only the PKs
I have attached here the code I have used. I don’t know how much it can help you.
Frankly, the media table on the web has only about 100 records (nearly 200MBs). I have a form in Servoy for that table. When I refer any one of the web forms in my method, the initial connection time takes 10mins and then the rest of the method is processed
Thanks
note: The attachment option is not visible in this forum. So I just paste here. Sorry..
application.setErrorCapture(true);
globals.errorCode = application.getLastErrorCode();
if (globals.stopUpload == 1 || globals.errorCode != 0 )return;
var btnName = arguments[0];
var param1 = arguments[1];
var param2 = arguments[2];
var param3 = arguments[3];
case "btnUploadAll":
uploadToWeb('uploadContact');
uploadToWeb('uploadProject');
uploadToWeb('uploadDocument');
uploadToWeb('uploadMedia','document_id_media_to_document');
uploadToWeb('deleteWebMedia');
if (globals.stopUpload != 1 && globals.errorCode == 0 ) {
plugins.dialogs.showInfoDialog('Update Result', 'Successfully Uploaded !');
}
else if (globals.stopUpload == 1 ) {
plugins.dialogs.showErrorDialog("Upload Cancelled ","Please Upload again for proper website operation ! ");
}
else if (globals.errorCode == 1 ) {
plugins.dialogs.showErrorDialog("Upload Error ","Please Check your internet connection and Upload again ! ");
}
globals.nav_closeFormInDialog();
break;
case "uploadContact":
var frmLocal = forms.frmContactList;
var frmWeb = forms.frmWebContact;
uploadToWeb('checkOkForWeb',frmLocal);
uploadToWeb('upload',frmLocal,frmWeb);
break;
case "uploadProject":
var frmLocal = forms.frmProjectList;
var frmWeb = forms.frmWebProject;
uploadToWeb('checkOkForWeb',frmLocal);
uploadToWeb('upload',frmLocal,frmWeb);
break;
case "uploadDocument":
var frmLocal = forms.frmDocumentList;
var frmWeb = forms.frmWebDocument;
uploadToWeb('checkOkForWeb',frmLocal);
uploadToWeb('upload',frmLocal,frmWeb);
break;
case "uploadMedia":
var frmLocal = forms.frmMediaList;
var frmWeb = forms.frmWebMedia;
var relation = param1;
frmLocal.controller.find();
frmLocal.uploaded = 0;
frmLocal[relation].ok_for_web = 1;
globals.newWebRecordCount = frmLocal.controller.search();
uploadToWeb('upload',frmLocal,frmWeb);
break;
case "checkOkForWeb":
var frmLocal = param1;
frmLocal.controller.find();
frmLocal.ok_for_web = "1";
globals.newWebRecordCount = frmLocal.controller.search();
break;
case "upload":
var frmLocal = param1;
var frmWeb = param2;
var tableName = frmLocal.controller.getTableName()
var table =databaseManager.getTable(frmLocal.controller.getServerName(),tableName);
var columnNameArray = table.getColumnNames();
//*********** THE COLUMN NAMES ARE SAME ON BOTH LOCAL & WEB SERVER **********//
if ( globals.newWebRecordCount > 0 ){
if (frmLocal != forms.frmMediaList){
frmWeb.controller.deleteAllRecords();
}
globals.utilities('setProgressionPresets', forms.frmWebUpdateProgression, 'progress', globals.newWebRecordCount);
for ( var i = 1 ; i <= globals.newWebRecordCount ; i++ ) {
if (globals.stopUpload == 1 || application.getLastErrorCode() != 0){
globals.errorCode = application.getLastErrorCode()
break;
}
var record = frmLocal.foundset.getRecord(i);
if (frmWeb == forms.frmWebMedia){
frmWeb.controller.find();
frmWeb.media_id = record['media_id'];
var duplicate = frmWeb.controller.search();
if (duplicate > 0){
frmWeb.controller.deleteRecord();
}
}
frmWeb.controller.newRecord();
for(var j=0;j<columnNameArray.length;j++){
frmWeb[columnNameArray[j]] = record[columnNameArray[j]];
}
if (frmLocal == forms.frmMediaList){
record['uploaded'] = 1;
}
globals.utilities('increaseProgression', forms.frmWebUpdateProgression, 'progress', i+1, frmWeb.controller.getName().substring(6));
frmWeb.controller.saveData();
}
}
break;
// DELETE THE MEDIA FILES IN WEB WHICH ARE NO MORE NEEDED ON THE WEB
case "deleteWebMedia":
//========================================================//
var frmMediaLocal = forms.frmMediaList;
frmMediaLocal.controller.loadAllRecords();
var dataArray = databaseManager.getFoundSetDataProviderAsArray(frmMediaLocal.foundset, "media_id");
var idString = "";
var totalRows = dataArray.length;
globals.utilities('setProgressionPresets', forms.frmWebUpdateProgression, 'progress', totalRows);
for (i=0; i<totalRows ; i++){
idString += "'" + dataArray[i] + "',";
}
if ( utils.stringRight(idString,1) == ","){
idString = utils.stringMiddle(idString,1, idString.length -1)
}
//========================================================//
var SQL = "SELECT media_id " +
"FROM media WHERE media_id NOT IN (" + idString + ")";
var dataset = databaseManager.getDataSetByQuery(globals.webServerName, SQL, null, 10000000);
forms.frmWebMedia.controller.loadRecords(dataset);
forms.frmWebMedia.controller.deleteAllRecords();
globals.utilities('increaseProgression', forms.frmWebUpdateProgression, 'progress', totalRows, 'Deleting Media');
break;
}