Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit ff8b827

Browse files
danolivoAlena Rybakina
authored andcommitted
Slightly refactor patch on query max size.
1 parent 4d3a687 commit ff8b827

File tree

5 files changed

+10
-7
lines changed

5 files changed

+10
-7
lines changed

aqo.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -238,10 +238,10 @@ _PG_init(void)
238238
NULL
239239
);
240240

241-
DefineCustomIntVariable("aqo.max_size",
241+
DefineCustomIntVariable("aqo.querytext_max_size",
242242
"Query max size in aqo_query_texts.",
243243
NULL,
244-
&max_size,
244+
&querytext_max_size,
245245
1000,
246246
0, INT_MAX,
247247
PGC_SUSET,

aqo_shared.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ HTAB *fss_htab = NULL;
2828
static int aqo_htab_max_items = 1000;
2929
int fs_max_items = 1; /* Max number of different feature spaces in ML model */
3030
int fss_max_items = 1; /* Max number of different feature subspaces in ML model */
31-
int max_size = 1000;
3231
static uint32 temp_storage_size = 1024 * 1024 * 10; /* Storage size, in bytes */
3332
static dsm_segment *seg = NULL;
3433

aqo_shared.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ extern HTAB *fss_htab;
5252

5353
extern int fs_max_items; /* Max number of feature spaces that AQO can operate */
5454
extern int fss_max_items;
55-
extern int max_size;
55+
extern int querytext_max_size;
5656

5757
extern Size aqo_memsize(void);
5858
extern void reset_dsm_cache(void);

storage.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ typedef void* (*form_record_t) (void *ctx, size_t *size);
6464
typedef void (*deform_record_t) (void *data, size_t size);
6565

6666

67+
int querytext_max_size = 1000;
68+
6769
HTAB *stat_htab = NULL;
6870
HTAB *queries_htab = NULL;
6971
HTAB *qtexts_htab = NULL;
@@ -934,7 +936,7 @@ aqo_qtext_store(uint64 queryid, const char *query_string)
934936

935937
Assert(!LWLockHeldByMe(&aqo_state->qtexts_lock));
936938

937-
if (query_string == NULL)
939+
if (query_string == NULL || querytext_max_size == 0)
938940
return false;
939941

940942
dsa_init();
@@ -969,7 +971,7 @@ aqo_qtext_store(uint64 queryid, const char *query_string)
969971
}
970972

971973
entry->queryid = queryid;
972-
size = size > max_size ? max_size : size;
974+
size = size > querytext_max_size ? querytext_max_size : size;
973975
entry->qtext_dp = dsa_allocate(qtext_dsa, size);
974976
Assert(DsaPointerIsValid(entry->qtext_dp));
975977
strptr = (char *) dsa_get_address(qtext_dsa, entry->qtext_dp);
@@ -1641,7 +1643,7 @@ aqo_queries(PG_FUNCTION_ARGS)
16411643
while ((entry = hash_seq_search(&hash_seq)) != NULL)
16421644
{
16431645
memset(nulls, 0, AQ_TOTAL_NCOLS + 1);
1644-
1646+
16451647
values[AQ_QUERYID] = Int64GetDatum(entry->queryid);
16461648
values[AQ_FS] = Int64GetDatum(entry->fs);
16471649
values[AQ_LEARN_AQO] = BoolGetDatum(entry->learn_aqo);

storage.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,8 @@ typedef struct QueriesEntry
8282
bool auto_tuning;
8383
} QueriesEntry;
8484

85+
extern int querytext_max_size;
86+
8587
extern HTAB *stat_htab;
8688
extern HTAB *qtexts_htab;
8789
extern HTAB *queries_htab; /* TODO */

0 commit comments

Comments
 (0)