Recently i came across a nice feature called "AvoidUsingProjections" that can be used in Vertica, it is actually an option that can be used with the set_optimizer_directives Vertica function.
What is the point of using this ?
Well maybe Vertica doesn't choose the best projection for you and you decide to tell Vertica what projection to use(you force the use of a specific projection)
Basic Syntax:
SELECT set_optimizer_directives('AvoidUsingProjections=proj1,proj2,...');
(dbadmin@:5433) [dbadmin] select projection_name from projections where anchor_table_name='dc_proj_used';
projection_name
-----------------
dc_proj_used_b0
dc_proj_used_b1
dbadmin@:5433) [dbadmin] explain select * from dc_proj_used;
QUERY PLAN DESCRIPTION:
------------------------------
explain select * from dc_proj_used;
Access Path:
+-STORAGE ACCESS for dc_proj_used [Cost: 547, Rows: 2K] (PATH ID: 1)
| Projection: test.dc_proj_used_b0
SELECT set_optimizer_directives('AvoidUsingProjections=test.dc_proj_used_b0');
QUERY PLAN DESCRIPTION:
------------------------------
Optimizer Directives
----------------------
AvoidUsingProjections=test.dc_proj_used_b0
explain select * from dc_proj_used;
Access Path:
+-STORAGE ACCESS for dc_proj_used [Cost: 547, Rows: 2K] (PATH ID: 1)
| Projection: test.dc_proj_used_b1
SELECT set_optimizer_directives('AvoidUsingProjections=')
SELECT set_optimizer_directives('AvoidUsingProjections=test.dc_proj_used_b0,test.dc_proj_used_b1');
(dbadmin@:5433) [dbadmin] explain select * from dc_proj_used;
ERROR 3586: Insufficient projections to answer query
DETAIL: No projections eligible to answer query
HINT: Projection dc_proj_used_b1 not used in the plan because the projection is not allowed because of current optimizer directives.
Projection dc_proj_used_b0 not used in the plan because the projection is not allowed because of current optimizer directives.