3 ms·
> “Select ” will almost certainly be optimized away by the execution plan What do you mean? Ask for all the columns, you're gonna get all the columns in a res
by sk5t 6y ago
> “Select ” will almost certainly be optimized away by the execution plan
What do you mean? Ask for all the columns, you're gonna get all the columns in a resultset. Only in a subquery could the planner know what is unused.
'select ' is _perhaps_ tolerable for creating a view--under the conditions that the database transforms the query into the unambiguous named columns at view creation time--and that's about it.
- pfarrell 6y agoYou’re right. When I wrote that, I was thinking higher up the chain in an orm layer. Sending “select *” to the db can’t be “optimized away” at that layer, it will have to return all the columns. Unless, like you said, the scope of the “select *” contains it in a sub query where the columns used can be known... “it depends :)”