In my limited experience in working with ORMs (so far LLBL Gen Pro and Entity Framework 4), I've noticed that inherently, queries return data for all columns. I know NHibernate is another popular ORM, and I'm not sure that this applies with it or not, but I would assume it does.
Of course, I know there are workarounds:
- Create a SQL view and create models and mappings on the view
- Use a stored procedure and create models and mappings on the result set returned
I know that adhering to certain practices can help mitigate this:
- Ensuring your row counts are reasonably limited when selecting data
- Ensuring your tables aren't excessively wide (large number of columns and/or large data types)
So here are my questions:
Are the above practices sufficient, or should I still consider finding ways to limit the number of columns returned?
Are there other ways to limit returned columns other than the ones I listed above?
How do you typically approach this in your projects?
Thanks in advance.
UPDATE: This sort of stems from the notion that SELECT *
is thought of as a bad practice. See this discussion.
SELECT *
as a bad practice. Of course, I know this is a bit different, as part of this is because it returns all rows even when your table changes -- and ORMs won't suffer from this problem. But the other argument is bandwidth consumption, which does apply to ORMs. – Designedly