Re: BUG #16888: Reoccurring group by clauses makes system slower

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: liuxy(at)gatech(dot)edu
Cc: pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Re: BUG #16888: Reoccurring group by clauses makes system slower
Date: 2021-02-23 15:12:13
Message-ID: 3821998.1614093133@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

PG Bug reporting form <noreply(at)postgresql(dot)org> writes:
> We have 2 TPC-H queries which fetch the same tuples but have significant
> query execution time differences (3.8 times).
> ...
> Since these two queries are semantically equivalent, we were hoping that
> PostgreSQL will evaluate them in roughly the same amount of time. It looks
> to me that the query optimizer does not realize the inner GROUP BY clause is
> unnecessary given the outer GROUP BY clause.

TBH, you are wasting your time reporting these sorts of things as bugs.
They are not bugs, unless equivalent queries give different answers.
At most, they represent optimizations nobody has bothered to put in.

In cases where the problem is really a visibly-badly-written query
(e.g., redundant GROUP BY clauses, as here), it's unclear that we'd
accept such an optimization if it were proposed, because adding checks
for such cases would necessarily penalize well-written queries to benefit
badly-written ones. The overhead would have to be extremely small, or
else the change would need to have some other benefit that accrues to
well-written queries as well as badly-written ones.

regards, tom lane

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Adrian Klaver 2021-02-23 15:26:57 Re: pg_restore - generated column - not populating
Previous Message Santosh Udupi 2021-02-23 14:36:26 Re: pg_restore - generated column - not populating