Skip to content

What is sequentially selects

mariuz edited this page Oct 16, 2014 · 4 revisions

A sequentially "select" is a "select" which retrieves each row separately. Example: we have a big table with 1 000 000 rows and we need to serialize rows into JSON e.g. HTTP response. So this is what we can do:

res.write('[');
  db.sequentially(query, [params], function(row, index) {
  res.write(JSON.stringify(row) + ',');
  }, function(err) {
  res.end(']');
});

This feature does not allocate much memory (because each row is not added into array (in background)). I didn't find any better name.