Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 1aea13f

Browse files
author
Alena Rybakina
committed
Load neighbours with the fss hash except dublicated neighours.
Rewrite test for look-a-like functional. Current tests contain correlation columns and queries have more nodes and description features. Add aqo_k as custom parameter to define few number of features for prediction. Its default value is 3. Queries can contain a larger number of features than 3 especially generic queries. Also add predict_a_few_neibours parameter for switch avalable to predict a few neibors than 3. It is done for not to change the previous logic of the code
1 parent 3255626 commit 1aea13f

File tree

8 files changed

+543
-198
lines changed

8 files changed

+543
-198
lines changed

‎aqo.c‎

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ void _PG_init(void);
3434
/* Strategy of determining feature space for new queries. */
3535
int aqo_mode = AQO_MODE_CONTROLLED;
3636
bool force_collect_stat;
37+
bool aqo_predict_with_few_neighbors;
3738

3839
/*
3940
* Show special info in EXPLAIN mode.
@@ -71,7 +72,7 @@ int auto_tuning_infinite_loop = 8;
7172
/* Machine learning parameters */
7273

7374
/* The number of nearest neighbors which will be chosen for ML-operations */
74-
int aqo_k=3;
75+
int aqo_k;
7576
double log_selectivity_lower_bound = -30;
7677

7778
/*
@@ -293,6 +294,29 @@ _PG_init(void)
293294
NULL
294295
);
295296

297+
DefineCustomIntVariable("aqo.k_neighbors_threshold",
298+
"Set the threshold of number of neighbors for predicting.",
299+
NULL,
300+
&aqo_k,
301+
3,
302+
1, INT_MAX / 1000,
303+
PGC_USERSET,
304+
0,
305+
NULL,
306+
NULL,
307+
NULL);
308+
309+
DefineCustomBoolVariable("aqo.predict_with_few_neighbors",
310+
"Make prediction with less neighbors than we should have.",
311+
NULL,
312+
&aqo_predict_with_few_neighbors,
313+
true,
314+
PGC_USERSET,
315+
0,
316+
NULL,
317+
lc_assign_hook,
318+
NULL);
319+
296320
prev_shmem_startup_hook = shmem_startup_hook;
297321
shmem_startup_hook = aqo_init_shmem;
298322
prev_planner_hook = planner_hook;

‎aqo.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,7 @@ extern double auto_tuning_convergence_error;
217217
/* Machine learning parameters */
218218

219219
extern int aqo_k;
220+
extern bool aqo_predict_with_few_neighbors;
220221
extern double log_selectivity_lower_bound;
221222

222223
/* Parameters for current query */

‎cardinality_estimation.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ predict_for_relation(List *clauses, List *selectivities, List *relsigns,
9393
*/
9494

9595
/* Try to search in surrounding feature spaces for the same node */
96-
if (!load_aqo_data(query_context.fspace_hash, *fss, data, NULL, use_wide_search))
96+
if (!load_aqo_data(query_context.fspace_hash, *fss, data, NULL, use_wide_search, features))
9797
result = -1;
9898
else
9999
{

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /