Re: Is it possible and worthy to optimize scanRTEForColumn()? - Mailing list pgsql-hackers

From Tom Lane
Subject Re: Is it possible and worthy to optimize scanRTEForColumn()?
Date
Msg-id 9069.1512745517@sss.pgh.pa.us
Whole thread Raw
In response to Is it possible and worthy to optimize scanRTEForColumn()?  (Rui Hai Jiang <ruihaijiang@msn.com>)
Responses Re: Is it possible and worthy to optimize scanRTEForColumn()?
List pgsql-hackers
Rui Hai Jiang <ruihaijiang@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"
existsor 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


pgsql-hackers by date:

Previous
From: "David G. Johnston"
Date:
Subject: Re: proposal: alternative psql commands quit and exit
Next
From: Ryan Murphy
Date:
Subject: Re: proposal: alternative psql commands quit and exit