A
A
Alexander2016-10-31 11:02:58
SQL
Alexander, 2016-10-31 11:02:58

Very slow SQL speed in NODE + tedious (AZURE), what could be the problem?

test middleware:

exports.Test = function (req, res, next)  {


var id = 1;
var param = 'test';

var bodyParser = require('body-parser');   
var Connection = require('tedious').Connection; 

 var config = {  
  // тут  конфиг БД
        options: {encrypt: true, database: 'database'}  
   };
 
var Request = require('tedious').Request;  
var TYPES = require('tedious').TYPES; 


  var connection = new Connection(config);  
    connection.on('connect', function(err) {    
        executeStatement();  
    });   
    
function  executeStatement() {
    
      request = new Request("select * from dbo.Table where param= '"+param+"' AND Id= '"+id+"' ", function(err, rowCount) {
            res.send(JSON.stringify(menues));
      });
      
      
var menues = new Array();

      request.on('row', function(columns) {
         columns.forEach(function(column) {
         menues.push(column.value);
         });

      });
      connection.execSql(request);
   }
}

I get json in about 3 - 4 seconds!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
Y
yeti357, 2016-11-03
@yeti357

can because on each request connection with a DB is established?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question