mysql - Load data infile slow executing from node js -


i'm trying insert more 600,000 rows in table script written in node js using next query.

var sql =   " load data local infile '/tmp/insertfile18.csv'" +                      " table `pricing_leasing`"  +                       " fields terminated ','  lines terminated '+-'"; 

the problem never finishes (i waited 1 hour on lunch), neither give error. executed directly in bash , fast, less 1 minute. decided write little script in nodejs doesn't else except execute script , finishes in 2 minutes ok.

my question why if execute query in bash or in it's own node js script work fine, if have more stuff going on before (other queries on different tables & file operations) became slow.

update

function uploadfile() {  var deferred    = global.q.defer(),     strfilename = "/tmp/insertfile" + global.company.id + ".csv",     cb = function ( err ) {         //fs.unlinksync( strfilename );         if ( err ) {             console.log( err );              global.objrstofinsert['success'] = false;         } else {             // update return structure success message             global.objrstofinsert['success'] = true;         }         console.log("finished uploads");         deferred.resolve();     };      var lstinsertpricingcolumns = '(`sourcecompany_id`,'+                             '`company_id`,'+                             '`price`,`active`,`row_hash`)';      var sql =   " load data local infile '" + strfilename + "'" +                  " table " + global.company.tableinsert +                    " fields terminated ','  lines terminated '+-'"+                  lstinsertpricingcolumns;      global.db['rates'].query( sql, cb );     return deferred.promise; }  

the problem cloud server have less ram local. guess file big. fixed splitting in multiples smaller files load data , work fine.

thanks.


Comments

Popular posts from this blog

1111. appearing after print sequence - php -

java - WARN : org.springframework.web.servlet.PageNotFound - No mapping found for HTTP request with URI [/board/] in DispatcherServlet with name 'appServlet' -

Ruby on Rails, ActiveRecord, Postgres, UTF-8 and ASCII-8BIT encodings -