Filtering Data Using Xpath vs Filter List Operation

0
Hello everyone,    I have a list of Newsletter objects, and I only want to retrieve the objects that have its IsSent attribute equals to false. I have two solution:   1- Retrieve the object with the xpath constraint:   2- Get all the Newsletter objects and filter them with list operation activity.   My question is, is there a difference between these two solutions in terms of performance?   And is there a better way to retrieve my filtered datas?  
asked
1 answers
1

The first option is the better option. Here you are retrieving a list of required objects that you need to work on using one query.

In the second option, you are retrieving a list of all objects of that entity which are not required and are creating another list in memory with a lot of duplicate objects. These objects are all transferred to the client and stored in client memory unless dealt with appropriately. 

 

This will be very clear if all the objects of a single entity are in millions and all you want is a small chunk, it is wise to retrieve only required objects instead of using up all memory and causing Out of memory error.

answered