FW: Column Cardinality and its influence on a Projection's sort order
Michael Flower
EMEA Vertica Systems Engineer
(M)+44 7793 757 623
Michael.Flower@microfocus.com
From: Flower, Michael (Vertica Presales)
Sent: 25 October 2018 10:48
To: Vertica Only Presales
Cc: ronald-paul.rong@microfocus.com
Subject: Column Cardinality and its influence on a Projection's sort order
Hello,
I have been asked a question by a customer, and it's got me thinking about some of the advice offered in our docs:
- https://www.vertica.com/docs/latest/HTML/index.htm#Authoring/AdministratorsGuide/ConfiguringTheDB/PhysicalSchema/ChoosingSortOrderBestPractices.htm
- https://www.vertica.com/docs/latest/HTML/index.htm#Authoring/AnalyzingData/Optimizations/OptimizingProjectionsForQueriesWithPredicates.htm
To improve query performance, we generally advise to try ordering the projections by lowest cardinality to higher cardinality.
Is this advice really true? If instead we sort firstly on the higher cardinality columns, then surely the optimizer can filter more rows sooner?
Let's say we have a 3-column table:
- Highcardinality
- Lowcardinality
- value
And a query
SELECT SUM(value) FROM table
WHERE Highcardinality = 12
AND Lowcardinality = 'Male';
If we create 2 projections on the table:
* "projection1" sorted on highcardinality, lowcardinality
* "projection2" sorted on lowcardinality,highcardinality
Which would the optimizer choose? It would choose Projection1. Well It does in my tests (using the online_sales.online_sales_fact table from Vmart).
And what does the DBD advise? If instead we don't create any projections, and we just run the query through the DBD, it also suggests projection1 (sorted on highcardinality, lowcardinality)
Maybe I am missing something, but I need to bounce this off someone (you!).
Any thoughts?
Regards, Mike
Michael Flower
EMEA Vertica Systems Engineer
(M)+44 7793 757 623
Michael.Flower@microfocus.com
EMEA Vertica Systems Engineer
(M)+44 7793 757 623
Michael.Flower@microfocus.com
From: Flower, Michael (Vertica Presales)
Sent: 25 October 2018 10:48
To: Vertica Only Presales
Cc: ronald-paul.rong@microfocus.com
Subject: Column Cardinality and its influence on a Projection's sort order
Hello,
I have been asked a question by a customer, and it's got me thinking about some of the advice offered in our docs:
- https://www.vertica.com/docs/latest/HTML/index.htm#Authoring/AdministratorsGuide/ConfiguringTheDB/PhysicalSchema/ChoosingSortOrderBestPractices.htm
- https://www.vertica.com/docs/latest/HTML/index.htm#Authoring/AnalyzingData/Optimizations/OptimizingProjectionsForQueriesWithPredicates.htm
To improve query performance, we generally advise to try ordering the projections by lowest cardinality to higher cardinality.
Is this advice really true? If instead we sort firstly on the higher cardinality columns, then surely the optimizer can filter more rows sooner?
Let's say we have a 3-column table:
- Highcardinality
- Lowcardinality
- value
And a query
SELECT SUM(value) FROM table
WHERE Highcardinality = 12
AND Lowcardinality = 'Male';
If we create 2 projections on the table:
* "projection1" sorted on highcardinality, lowcardinality
* "projection2" sorted on lowcardinality,highcardinality
Which would the optimizer choose? It would choose Projection1. Well It does in my tests (using the online_sales.online_sales_fact table from Vmart).
And what does the DBD advise? If instead we don't create any projections, and we just run the query through the DBD, it also suggests projection1 (sorted on highcardinality, lowcardinality)
Maybe I am missing something, but I need to bounce this off someone (you!).
Any thoughts?
Regards, Mike
Michael Flower
EMEA Vertica Systems Engineer
(M)+44 7793 757 623
Michael.Flower@microfocus.com
Sign up
Already have an account? Login
Welcome to the Rocket Forum!
Please log in or register:
Employee Login | Registration Member Login | RegistrationEnter your E-mail address. We'll send you an e-mail with instructions to reset your password.