From: | Jim Finnerty <jfinnert(at)amazon(dot)com> |
---|---|
To: | pgsql-hackers(at)postgresql(dot)org |
Subject: | Re: Removing useless DISTINCT clauses |
Date: | 2018-03-23 12:42:47 |
Message-ID: | 1521808967627-0.post@n3.nabble.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
David, first of all, I'm delighted to see this change. I've been intending
to give you feedback on it for a while, but I've been flat out with work, so
I'm sorry.
Any improvement in our DISTINCT optimization would be helpful. Note,
though, that DISTINCT optimization can include the surrounding query block
context, because sometimes the DISTINCT is required, sometimes it is
prohibited, and sometimes it is optional. When DISTINCT is optional, you
can produce distinct rows if it is efficient and convenient to do so, as you
might from an index scan having leading keys that match the DISTINCT, but
you
Consider if you have a SELECT DISTINCT under a UNION that does a distinct on
the same grouping keys. In that case, the UNION will do the distinct
operation anyway, so the SELECT DISTINCT can become a SELECT.
Please search for and read the old-but-good paper entitled "Extensible/Rule
Based Query Optimization in Starburst", by Pirahesh et. al.
Distinctness can also be preserved across joins, so if you have a 'snowflake
query' type join, where all the joins are to a unique key, then the
distinctness of the other side of the join is preserved. For example, a
SELECT DISTINCT * FROM fact_table ... that joins from each column in its
compound primary key to a unique key of another (dimension) table would
remain distinct, and so you could drop the DISTINCT from the query.
This is a relatively weak area of PostgreSQL at the moment, so IMHO we
really need this.
Regarding constraint OIDs and invalidation when a NOT NULL column is
modified to remove this constraint, this would be accomplished with an ALTER
TABLE <t> ALTER COLUMN <c> <type> NULL.
Why wouldn't / can't the ALTER TABLE cause an invalidation of cached plans
that depend on table t?
--
Sent from: http://www.postgresql-archive.org/PostgreSQL-hackers-f1928748.html
From | Date | Subject | |
---|---|---|---|
Next Message | Robert Haas | 2018-03-23 12:56:49 | Re: [HACKERS] Add support for tuple routing to foreign partitions |
Previous Message | Amit Langote | 2018-03-23 12:33:57 | Re: [HACKERS] MERGE SQL Statement for PG11 |