Re: Patch for removng unused targets - Mailing list pgsql-hackers

From Hitoshi Harada
Subject Re: Patch for removng unused targets
Date
Msg-id CAP7QgmnETeD3QtPh82uwfUy0Wh1wiZbF-X7OrrBfTfvWVe3b-Q@mail.gmail.com
Whole thread Raw
In response to Re: Patch for removng unused targets  ("Etsuro Fujita" <fujita.etsuro@lab.ntt.co.jp>)
Responses Re: Patch for removng unused targets  ("Etsuro Fujita" <fujita.etsuro@lab.ntt.co.jp>)
List pgsql-hackers



On Wed, Jun 19, 2013 at 4:49 AM, Etsuro Fujita <fujita.etsuro@lab.ntt.co.jp> wrote:

Hi Harada-san,

 

Thank you for the review.

 

I think that the parse tree has enough information to do this optimization and that the easiest way to do it is to use the information, though I might not have understand your comments correctly.  So, I would like to fix the bug by simply modifying the removability check in adjust_targetlist() so that the resjunk column is not used in GROUP BY, DISTINCT ON and *window PARTITION/ORDER BY*, besides ORDER BY.  No?  I am open to any comments.

 


I guess the patch works fine, but what I'm saying is it might be limited to small use cases.  Another instance of this that I can think of is ORDER BY clause of window specifications, which you may want to remove from the target list as well, in addition to ORDER BY of query.  It will just not be removed by this approach, simply because it is looking at only parse->sortClause.  Certainly you can add more rules to the new function to look at the window specification, but then I'm not sure what we are missing.  So, as it stands it doesn't have critical issue, but more generalized approach would be desirable.  That said, I don't have strong objection to the current patch, and just posting one thought to see if others may have the same opinion.

Thanks,
--
Hitoshi Harada

pgsql-hackers by date:

Previous
From: Andrew Dunstan
Date:
Subject: Re: Bugfix and new feature for PGXS
Next
From: Cédric Villemain
Date:
Subject: Re: Bugfix and new feature for PGXS