Ionic 1 slow slow rendering when leave view /Sqlite update data

Hi! I developing an application using ionic1 and AngularJS.When i want to go back to previous view i must save some data into sqlite database using sqlite plugin from https://github.com/litehelpers/Cordova-sqlite-storage.git .When i press button to go back i see a lag when it pass from a view to another.The sqlite table structure have two columns:

->Id -primary key -integer

->data-string

In this table i want to save data field as string(from json). Does anyone knows how to make this process faster? I’m using an iPad for testing. I’m posting my code here to show how save function is implemented.Thanks for any help. :slight_smile:

$scope.storeProfileDataCourses = function(data) {
           console.log('insertData');
           var querySelect = "SELECT * FROM Table where Id=?";
           $cordovaSQLite.execute(db, querySelect, [crewId]).then(function(res) {
               console.log('Rows:' + res.rows.length);
               if (res.rows.length > 0) {
                   var queryUpdate = "UPDATE Table SET data=? WHERE Id=?";
                   $cordovaSQLite.execute(db, queryUpdate, [JSON.stringify(data), crewId]).then(function(res) {
                       console.log('update');
                       console.log(res);
                   }, function(err) {
                       console.error(err);
                   });
               } else {
                   console.log('Need to insert');
                   var query = "INSERT INTO Table(Id,data) VALUES (?,?)";
                   $cordovaSQLite.execute(db, query, [Id, JSON.stringify(data)]).then(function(res) {
                       console.log("INSERT ID -> " + res.insertId);
                   }, function(err) {
                       console.error(err);
                   });
               }
           });
       }