Re: Removing useless DISTINCT clauses

Поиск
Список
Период
Сортировка
От David Rowley
Тема Re: Removing useless DISTINCT clauses
Дата
Msg-id CAKJS1f_4row4Ou6qNXUaoPoOsDz7jD580SzSR3uzVqRU7wQ=sw@mail.gmail.com
обсуждение исходный текст
Ответ на Re: Removing useless DISTINCT clauses  (Melanie Plageman <melanieplageman@gmail.com>)
Ответы Re: Removing useless DISTINCT clauses  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-hackers
On 24 March 2018 at 05:55, Melanie Plageman <melanieplageman@gmail.com> wrote:
> I was just wondering, since get_primary_key_attnos opens pg_constraint and
> just skips attributes with other constraint types than primary, what would
> be the reason we wouldn't just also open pg_attribute and check for the
> non-nullness of the non-primary key unique attributes?
> Couldn't we add a function which opens both pg_attribute and pg_constraint
> to get non-null unique attributes?
> I suppose that would have a performance impact.
> And, I did notice the FIXME in the comment before check_functional_grouping
> which seems to make the argument that there are other use cases for wanting
> the non-nullness represented in pg_constraint.

It's certainly possible to do more here.  I'm uncertain what needs to
be done in regards to cached plan invalidation, but we'd certainly
need to ensure cached plans are invalidated whenever the attnotnull is
changed.

There would be no need to look at the pg_attribute table directly. A
syscache function would just need added named get_attnotnull() which
would be akin to something like get_atttypmod().

I'm personally not planning on doing anything in that regard for this
patch. We have 1 week to go before PG11 feature freeze. My goals for
this patch was to apply the same optimization to DISTINCT as I did for
GROUP BY a while back, which is exactly what the patch does. I agree
that more would be nice, but unfortunately, time is finite.

-- 
 David Rowley                   http://www.2ndQuadrant.com/
 PostgreSQL Development, 24x7 Support, Training & Services


В списке pgsql-hackers по дате отправления:

Предыдущее
От: David Rowley
Дата:
Сообщение: Re: Removing useless DISTINCT clauses
Следующее
От: David Rowley
Дата:
Сообщение: Re: Removing useless DISTINCT clauses