Check out example codes for "How to use node-mysql without loads all the rows into the memory? Ask Question". It will help you in understanding the concepts better.

Code Example 1

const mysql = require('mysql');
const stream = require('stream');

connection.query('SELECT * FROM `bigdata`')
  .on('error', function(err) {
    // Do something about error in the query
  .stream() // Stream allows you to get records one-by-one
  .pipe(new stream.Transform({
    objectMode: true,
    transform: function (row, encoding, callback) {
      // Do something with the row of data

  .on('finish', function() {

Learn ReactJs, React Native from