Does Java Bean in the resultset with empty columns affects memory/size significantly?
<p>This might sound a dumb question, but I could not find a lot of stuff about this (other than this article: <a href="https://plumbr.eu/blog/memory-leaks/reducing-memory-consumption-by-20x" rel="nofollow">https://plumbr.eu/blog/memory-leaks/reducing-memory-consumption-by-20x</a>). </p>

<p>The question is: We're going to query Oracle database table which has 20 columns. We created a Java bean which maps to all the 20 columns. Now using Spring JDBC, we execute a query which only selects 3 columns (out of 20) and we set only the three properties in the bean (total properties=20), which means the rest of the 17 properties should be null. Now we use this resultset (having 3 fields populated, but 17 as null) for processing, for passing on between layers etc. </p>

<p>Is this going to affect the total memory used by the Java program significantly, especially when we are going to pull few hundred DB records or Java would somehow internally optimize it? Would it be better to just create a bean which has only 3 fields (which we need as part of our query?)</p>

<p>We're using JDK 1.8, Spring 4, oracle 11.</p>