Skip to content

Commit 95de10e

Browse files
committed
Add commit for smooth transition to file-based AQO storage.
1 parent ce94043 commit 95de10e

File tree

5 files changed

+55
-2
lines changed

5 files changed

+55
-2
lines changed

aqo.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include "path_utils.h"
2424
#include "preprocessing.h"
2525
#include "learn_cache.h"
26+
#include "storage.h"
2627

2728

2829
PG_MODULE_MAGIC;
@@ -199,6 +200,18 @@ _PG_init(void)
199200
NULL
200201
);
201202

203+
DefineCustomBoolVariable(
204+
"aqo.use_file_storage",
205+
"Used for smooth transition from table storage",
206+
NULL,
207+
&aqo_use_file_storage,
208+
false,
209+
PGC_USERSET,
210+
0,
211+
NULL,
212+
NULL,
213+
NULL
214+
);
202215
DefineCustomIntVariable("aqo.join_threshold",
203216
"Sets the threshold of number of JOINs in query beyond which AQO is used.",
204217
NULL,

postprocessing.c

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
#include "machine_learning.h"
3030
#include "preprocessing.h"
3131
#include "learn_cache.h"
32+
#include "storage.h"
3233

3334

3435
typedef struct
@@ -823,7 +824,12 @@ aqo_ExecutorEnd(QueryDesc *queryDesc)
823824
}
824825

825826
if (query_context.collect_stat)
826-
stat = get_aqo_stat(query_context.query_hash);
827+
{
828+
if (!aqo_use_file_storage)
829+
stat = get_aqo_stat(query_context.query_hash);
830+
else
831+
stat = aqo_load_stat(query_context.query_hash);
832+
}
827833

828834
{
829835
/* Calculate execution time. */
@@ -873,7 +879,10 @@ aqo_ExecutorEnd(QueryDesc *queryDesc)
873879
automatical_query_tuning(query_context.query_hash, stat);
874880

875881
/* Write AQO statistics to the aqo_query_stat table */
876-
update_aqo_stat(query_context.query_hash, stat);
882+
if (!aqo_use_file_storage)
883+
update_aqo_stat(query_context.query_hash, stat);
884+
else
885+
aqo_store_stat(query_context.query_hash, stat);
877886
pfree_query_stat(stat);
878887
}
879888

preprocessing.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@
6565
#include "aqo.h"
6666
#include "hash.h"
6767
#include "preprocessing.h"
68+
#include "storage.h"
6869

6970

7071
/* List of feature spaces, that are processing in this backend. */

storage.c

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
#include "machine_learning.h"
2929
#include "preprocessing.h"
3030
#include "learn_cache.h"
31+
#include "storage.h"
3132

3233
#define AQO_DATA_COLUMNS (7)
3334
HTAB *deactivated_queries = NULL;
@@ -1104,3 +1105,22 @@ add_deactivated_query(uint64 query_hash)
11041105
{
11051106
hash_search(deactivated_queries, &query_hash, HASH_ENTER, NULL);
11061107
}
1108+
1109+
/* *****************************************************************************
1110+
*
1111+
* Implement AQO file storage below
1112+
*
1113+
**************************************************************************** */
1114+
1115+
bool aqo_use_file_storage;
1116+
1117+
void
1118+
aqo_store_stat(uint64 queryid, QueryStat * stat)
1119+
{
1120+
}
1121+
1122+
QueryStat *
1123+
aqo_load_stat(uint64 queryid)
1124+
{
1125+
return NULL;
1126+
}

storage.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#ifndef STORAGE_H
2+
#define STORAGE_H
3+
4+
#include "aqo.h"
5+
6+
extern bool aqo_use_file_storage;
7+
8+
extern void aqo_store_stat(uint64 queryid, QueryStat * stat);
9+
extern QueryStat *aqo_load_stat(uint64 queryid);
10+
#endif /* STORAGE_H */

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy