Re: Is it possible and worthy to optimize scanRTEForColumn()?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Rui Hai Jiang <ruihaijiang(at)msn(dot)com>
Cc: "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Is it possible and worthy to optimize scanRTEForColumn()?
Date: 2017-12-08 15:05:17
Message-ID: 9069.1512745517@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Rui Hai Jiang <ruihaijiang(at)msn(dot)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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Ryan Murphy 2017-12-08 15:09:37 Re: proposal: alternative psql commands quit and exit
Previous Message David G. Johnston 2017-12-08 14:53:20 Re: proposal: alternative psql commands quit and exit