Re: Any benefit to listing unused columns in SELECT statement?

From: Frank <fbortel_at_home.nl>
Date: Thu, 02 Jan 2003 21:04:54 +0100
Message-ID: <3E149B66.7010004_at_home.nl>


Larry Leonard wrote:
> I've inherited a large body of SQL statements, and many of them use
> this kind of idiom:
>
> select name, state, zip
> from customers
> where state = 'NY'
> and zip = '11011';
>
> The interesting part is that (this is oo4o, BTW), only the 'name'
> value is used later on in the (C++) program. So, it looks to me as if
> (a) the original author thought that if a column appeared in the where
> clause, it had to also appear in the select clause, or (b) this is
> some obscure Oracle tuning custom I'm unfamiliar with.
>
> Any ideas? TIA.

afair, if there would be a compound index (name, state, zip) the above query would use that (similar like an index only table, or iot). Your query would not, as state and zip are not the most significant fields in that index.

Frank Received on Thu Jan 02 2003 - 21:04:54 CET

Original text of this message