Replies: 2 comments 1 reply
-
The above doc is mainly from Paulley's paper: Exploiting Functional Dependence in Query Optimization. Thank him for the formal analysis work. |
Beta Was this translation helpful? Give feedback.
0 replies
-
Hi, @AngleNet. Thanks for your contribution! However, this draft RFC is not actionable to me:
Hoping those concerns can be addressed in the future. BTW, take a look at this RFC example will be great! |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Motivation
When we create a table, we could specify primary key, unique indexes, unique constraints for it. These constraints could be further exploited via functional dependencies between attributes while optimizing queries, such as calculating cost more accurately, removing unnecessary operators.
For example, there is a table
create table tb(a int)
and a queryselect distinct a + 1 from tb
. The attributea
functionally determinesa+1
. Ifa
is a primary key, we could rewrite the query toselect a+1 from tb
by removing unnecessarydistinct
which could introduce asort
operator to eliminate duplicates.Design Goal
distinct
elimination.Concepts
The main concepts involved in this doc are borrowed from [1]. We just list the most fundamental ones here.
select a as b, a from numbers
. We could sayBasic Idea
We represent functional dependencies and equivalence constraint both in a directed hypergraph in which vertexes are determinants and dependents, edges are dependencies and constraints. To determine the set of dependencies that hold in an entire expression$e$ , one can simply recursively traverse the expression tree in a postfix manner and compute the dependencies and equivalence constraint that hold for a given operator once the dependencies and equivalence constraint of its inputs have been determined. The algorithm details are listed in [1].
Implementations
later
Prototype
later
References
[1] Exploiting Functional Dependence in Query Optimization
Beta Was this translation helpful? Give feedback.
All reactions