Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GoogleScript loading JDBC ResultSet into Array is very slow / how to optimize?

I'm using JDBC on GoogleScript to communicate with GoogleCloud MySQL.

My table has 24 columns and it takes about 30 seconds for a 1000 row ResultSet to be loaded into the array. The loop in the code block below takes up most of that time.

Did I make any mistakes that caused it to be this slow? Is there a way to optimize this? Are there better approaches?

var results = stmt.executeQuery(query);

  results.last();
  var nrow = results.getRow()
  results.first();
  var ncol = results.getMetaData().getColumnCount();

  var dat = new Array(nrow);
  for (var i = 0; i<nrow; i++){
    dat[i]=new Array(ncol);
    for(var j = 0; j<ncol; j++){
      dat[i][j] = results.getString(j+1);
    }
    results.next();
  }
like image 931
Isaac Avatar asked May 30 '20 19:05

Isaac


1 Answers

Had the same problem and realized that it was caused by the new V8 runtime migration. I went back to the old one and it worked, it got faster. I don´t really know why it's not working well with the new version... it's supposed to be better =/

Anyway, you can change back to the old Rhino version in the menu Run > Disable new Apps Script powered by V8.

Hope this helps. Good luck!

like image 56
Erika Avatar answered Oct 25 '22 01:10

Erika