Re: Removing useless DISTINCT clauses
От | Jim Finnerty |
---|---|
Тема | Re: Removing useless DISTINCT clauses |
Дата | |
Msg-id | 1521808967627-0.post@n3.nabble.com обсуждение исходный текст |
Ответ на | Re: Removing useless DISTINCT clauses (David Rowley <david.rowley@2ndquadrant.com>) |
Ответы |
Re: Removing useless DISTINCT clauses
|
Список | 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
В списке pgsql-hackers по дате отправления: