Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 25 additions & 1 deletion aqo.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ void _PG_init(void);
/* Strategy of determining feature space for new queries. */
int aqo_mode = AQO_MODE_CONTROLLED;
bool force_collect_stat;
bool aqo_predict_with_few_neighbors;

/*
* Show special info in EXPLAIN mode.
Expand Down Expand Up @@ -71,7 +72,7 @@ int auto_tuning_infinite_loop = 8;
/* Machine learning parameters */

/* The number of nearest neighbors which will be chosen for ML-operations */
int aqo_k = 3;
int aqo_k;
double log_selectivity_lower_bound = -30;

/*
Expand Down Expand Up @@ -293,6 +294,29 @@ _PG_init(void)
NULL
);

DefineCustomIntVariable("aqo.min_neighbors_for_predicting",
"Set how many neighbors the cardinality prediction will be calculated",
NULL,
&aqo_k,
3,
1, INT_MAX / 1000,
PGC_USERSET,
0,
NULL,
NULL,
NULL);

DefineCustomBoolVariable("aqo.predict_with_few_neighbors",
"Establish the ability to make predictions with fewer neighbors than were found.",
NULL,
&aqo_predict_with_few_neighbors,
true,
PGC_USERSET,
0,
NULL,
NULL,
NULL);

prev_shmem_startup_hook = shmem_startup_hook;
shmem_startup_hook = aqo_init_shmem;
prev_planner_hook = planner_hook;
Expand Down
1 change: 1 addition & 0 deletions aqo.h
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@ extern double auto_tuning_convergence_error;
/* Machine learning parameters */

extern int aqo_k;
extern bool aqo_predict_with_few_neighbors;
extern double log_selectivity_lower_bound;

/* Parameters for current query */
Expand Down
2 changes: 1 addition & 1 deletion cardinality_estimation.c
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ predict_for_relation(List *clauses, List *selectivities, List *relsigns,
*/

/* Try to search in surrounding feature spaces for the same node */
if (!load_aqo_data(query_context.fspace_hash, *fss, data, NULL, use_wide_search))
if (!load_aqo_data(query_context.fspace_hash, *fss, data, NULL, use_wide_search, features))
result = -1;
else
{
Expand Down
Loading