Rui Hai Jiang <ruihaiji...@msn.com> writes: > When I run a select query, e.g. select id from t, all columns in table "t" > are checked to see if a column named "id" exists or not, and a Var is created > for "id" if the column does exist.
> Function scanRTEForColumn() does this job. > But I see in scanRTEForColumn(), the loop does not stop when a match is > found, it continues to compare all other columns. And this will waste lots of > computing. > I guess there may be some reasons for this. But I don't know yet. It's necessary because we have to check whether the column name is ambiguous. Although in the case of a table, the names are constrained to all be different, this is not the case for all RTE types ... nor even for table RTEs, if aliases have been applied. I'm not particularly concerned about it --- I've not seen profiles suggesting that that function is a big time sink. Tables with very many columns tend to be inefficient for lots of reasons, and I rather doubt that this particular place is the first thing to hit if you want to make that better. regards, tom lane