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

Load neighbours with the fss hash except dublicated neighours. #112

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Alena0704 wants to merge 4 commits into stable13 from 13-look-a-like
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
View file Open in desktop
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;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Должно быть задано значение по-умолчанию, которое совпадает с умолчальным в точке объявления GUC'a - иначе тесты мастера не пройдет.

Copy link
Collaborator Author

@Alena0704 Alena0704 Jan 24, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Да, значение по умолчанию берется равным 3.

int aqo_k;
double log_selectivity_lower_bound = -30;

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

DefineCustomIntVariable("aqo.k_neighbors_threshold",
"Set the threshold of number of neighbors for predicting.",
NULL,
&aqo_k,
3,
1, INT_MAX / 1000,
PGC_USERSET,
0,
NULL,
NULL,
NULL);

DefineCustomBoolVariable("aqo.predict_with_few_neighbors",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Этот параметр нужен только для тестирования или зачем? Стоит откомментировать его , иначе непонятна необходимость.

Copy link
Collaborator Author

@Alena0704 Alena0704 Jan 24, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Параметр нужен для того, чтобы не считались предсказания, если найдено меньшее количество соседей, чем задано в параметре min_neighbors_for_predicting. Без этой настройки, aqo сразу делает предсказание при одном найденном соседе, что может быть в некоторых случаях неверно.
Тут дается дополнительная возможность дождаться, когда aqo обучиться и запросов в базе знаний станет достаточно для получения средней оценки, например, на основе трех соседей.

"Make prediction with less neighbors than we should have.",
NULL,
&aqo_predict_with_few_neighbors,
true,
PGC_USERSET,
0,
NULL,
lc_assign_hook,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Зачем здесь эта ссылка на функцию?

Copy link
Collaborator Author

@Alena0704 Alena0704 Jan 24, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Поправила,ссылки нет.

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
View file Open in desktop
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
View file Open in desktop
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

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