Skip to content

Stable15 fix look a like #119

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
wants to merge 5 commits into from
Closed
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
9 changes: 2 additions & 7 deletions expected/smart_statement_timeout.out
Original file line number Diff line number Diff line change
Expand Up @@ -69,18 +69,13 @@ SET statement_timeout = 100; -- [0.1s]
SET aqo.statement_timeout = 150;
SELECT count(a.x1),count(B.y1) FROM A a LEFT JOIN B ON a.x1 = B.y1 LEFT JOIN A a1 ON a1.x1 = B.y1;
NOTICE: [AQO] Time limit for execution of the statement was expired. AQO tried to learn on partial data. Timeout is 63
NOTICE: [AQO] Time limit for execution of the statement was increased. Current timeout is 1728
count | count
--------+--------
563300 | 562500
(1 row)

ERROR: canceling statement due to statement timeout
select smart_timeout, count_increase_timeout from aqo_queries, aqo_query_texts
where query_text = 'SELECT count(a.x1),count(B.y1) FROM A a LEFT JOIN B ON a.x1 = B.y1 LEFT JOIN A a1 ON a1.x1 = B.y1;'
and aqo_query_texts.queryid = aqo_queries.queryid limit 1;
smart_timeout | count_increase_timeout
---------------+------------------------
1728 | 4
63 | 3
(1 row)

SELECT 1 FROM aqo_reset();
Expand Down
10 changes: 6 additions & 4 deletions expected/update_functions.out
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ ANALYZE aqo_test2;
CREATE EXTENSION aqo;
SET aqo.join_threshold = 0;
SET aqo.mode='intelligent';
SET enable_material = 'off';
SET enable_hashjoin = 'off';
SET enable_bitmapscan = 'off';
SET enable_mergejoin = 'off';
SELECT count(*) FROM aqo_test1 a, aqo_test2 b WHERE a.a=b.a;
count
-------
Expand Down Expand Up @@ -326,8 +330,7 @@ ORDER BY res;
t
t
t
t
(27 rows)
(26 rows)

-- Check if data is the same as in source, no result rows expected.
(TABLE aqo_data_dump EXCEPT TABLE aqo_data)
Expand Down Expand Up @@ -369,8 +372,7 @@ ORDER BY res;
t
t
t
t
(27 rows)
(26 rows)

-- Check if data is the same as in source, no result rows expected.
(TABLE aqo_data_dump EXCEPT TABLE aqo_data)
Expand Down
4 changes: 2 additions & 2 deletions postprocessing.c
Original file line number Diff line number Diff line change
Expand Up @@ -630,7 +630,7 @@ aqo_timeout_handler(void)
if (aqo_statement_timeout == 0)
elog(NOTICE, "[AQO] Time limit for execution of the statement was expired. AQO tried to learn on partial data.");
else
elog(NOTICE, "[AQO] Time limit for execution of the statement was expired. AQO tried to learn on partial data. Timeout is %ld", max_timeout_value);
elog(NOTICE, "[AQO] Time limit for execution of the statement was expired. AQO tried to learn on partial data. Timeout is "UINT64_FORMAT"", max_timeout_value);

learnOnPlanState(timeoutCtl.queryDesc->planstate, (void *) &ctx);
MemoryContextSwitchTo(oldctx);
Expand Down Expand Up @@ -827,7 +827,7 @@ aqo_ExecutorEnd(QueryDesc *queryDesc)
if ( aqo_learn_statement_timeout && aqo_statement_timeout > 0 && error >= 0.1)
{
int64 fintime = increase_smart_timeout();
elog(NOTICE, "[AQO] Time limit for execution of the statement was increased. Current timeout is %ld", fintime);
elog(NOTICE, "[AQO] Time limit for execution of the statement was increased. Current timeout is "UINT64_FORMAT"", fintime);
}

pfree(stat);
Expand Down
4 changes: 4 additions & 0 deletions sql/update_functions.sql
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ CREATE EXTENSION aqo;
SET aqo.join_threshold = 0;

SET aqo.mode='intelligent';
SET enable_material = 'off';
SET enable_hashjoin = 'off';
SET enable_bitmapscan = 'off';
SET enable_mergejoin = 'off';

SELECT count(*) FROM aqo_test1 a, aqo_test2 b WHERE a.a=b.a;
SELECT count(*) FROM aqo_test1 a, aqo_test2 b, aqo_test2 c WHERE a.a = b.a AND b.a = c.a;
Expand Down
4 changes: 2 additions & 2 deletions storage.c
Original file line number Diff line number Diff line change
Expand Up @@ -1513,7 +1513,7 @@ build_knn_matrix(OkNNrdata *data, const OkNNrdata *temp_data, double *features)

for (i = 0; i < data->rows; i++)
{
if (k < aqo_K && !neirest_neighbor(data->matrix, old_rows, data->matrix[i], data->cols))
if (k < aqo_K && !neirest_neighbor(data->matrix, old_rows, temp_data->matrix[i], data->cols))
{
memcpy(data->matrix[k], temp_data->matrix[i], data->cols * sizeof(double));
data->rfactors[k] = temp_data->rfactors[i];
Expand Down Expand Up @@ -1648,7 +1648,7 @@ load_aqo_data(uint64 fs, int fss, OkNNrdata *data, List **reloids,
}

temp_data = _fill_knn_data(entry, reloids);
build_knn_matrix(data, temp_data, features);
build_knn_matrix(data, temp_data, NULL);
}
else
/* Iterate across all elements of the table. XXX: Maybe slow. */
Expand Down