'Android Room fetch all entity from fetch only columns efficiency

I am developing a chat application and i use Room for store my data. I have a lot of queries going on from the database along the app lifecycle. Up to now when i want something from the Database i create a Pojo with the entities and the relations inlcuded so i end up fetch the whole entities from the database. I would like to know if it would be much more efficient to create Pojos with only the columns that i really need to display in the UI or use for some purpose anyway. Would it be more efficient in speed or memory?



Solution 1:[1]

Yes, it would be more efficient as you end up having to process less data, so a reduction in the memory usage and also the speed of retrieval.

However, the negative effect is that the code itself will be longer and thus result in a larger package to be installed. The code itself would be more complex and thus perhaps affect maintenance of the code.

How much more efficient could only be determined with testing as it would depend upon the reduction in the size of the underlying data.

It could well be that the gains and losses would be marginal though.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 MikeT