Are result of queries cached?

Are result of queries cached?

In case of a queries:

var unordered = DB.user.where(‘delete_on = ?’, null);

var orderedByLastName = unordered.orderBy(‘last_name’);

var orderedByFirstName = unordered.orderBy(‘first_name’);

Are queries equvalent to:

var orderedByLastName = DB.user.where(‘delete_on = ?’, null).orderBy(‘last_name’);

var orderedByFirstName = DB.user.where(‘delete_on = ?’, null).orderBy(‘first_name’);

or there is some cache process making the first case more efficient?

1 Like

Hi @lukas.danek

That is a great question.

Your example queries would be equivalent.

Only once you do a .toArray() would there be a difference (but obviously you cannot do a .orderBy() on the array, you would have to do a manual array.sort)