Skip to content

Commit 7aac413

Browse files
committed
update version aqo up to the current version
1 parent 4a7fcd7 commit 7aac413

8 files changed

Lines changed: 37 additions & 36 deletions

File tree

aqo.dylib

174 KB
Binary file not shown.

aqo.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ extern double predict_for_relation(List *restrict_clauses, List *selectivities,
282282
List *relsigns, int *fss);
283283

284284
/* Query execution statistics collecting hooks */
285-
bool aqo_ExecutorStart(QueryDesc *queryDesc, int eflags);
285+
void aqo_ExecutorStart(QueryDesc *queryDesc, int eflags);
286286
void aqo_ExecutorRun(QueryDesc *queryDesc, ScanDirection direction, uint64 count);
287287
void aqo_ExecutorEnd(QueryDesc *queryDesc);
288288

aqo_shared.c

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -43,51 +43,50 @@ aqo_init_shmem(void)
4343
aqo_state->qtexts_dsa_handler = DSM_HANDLE_INVALID;
4444
aqo_state->data_dsa_handler = DSM_HANDLE_INVALID;
4545

46-
aqo_state->qtext_trancheid = LWLockNewTrancheId();
46+
aqo_state->qtext_trancheid = LWLockNewTrancheId("AQO Query Texts Tranche");
4747

4848
aqo_state->qtexts_changed = false;
4949
aqo_state->stat_changed = false;
5050
aqo_state->data_changed = false;
5151
aqo_state->queries_changed = false;
5252
aqo_state->bgw_handle = NULL;
5353

54-
LWLockInitialize(&aqo_state->lock, LWLockNewTrancheId());
55-
LWLockInitialize(&aqo_state->stat_lock, LWLockNewTrancheId());
56-
LWLockInitialize(&aqo_state->qtexts_lock, LWLockNewTrancheId());
57-
LWLockInitialize(&aqo_state->data_lock, LWLockNewTrancheId());
58-
LWLockInitialize(&aqo_state->queries_lock, LWLockNewTrancheId());
54+
LWLockInitialize(&aqo_state->lock,
55+
LWLockNewTrancheId("AQO"));
56+
LWLockInitialize(&aqo_state->stat_lock,
57+
LWLockNewTrancheId("AQO Stat Lock Tranche"));
58+
LWLockInitialize(&aqo_state->qtexts_lock,
59+
LWLockNewTrancheId("AQO QTexts Lock Tranche"));
60+
LWLockInitialize(&aqo_state->data_lock,
61+
LWLockNewTrancheId("AQO Data Lock Tranche"));
62+
LWLockInitialize(&aqo_state->queries_lock,
63+
LWLockNewTrancheId("AQO Queries Lock Tranche"));
5964
}
6065

6166
info.keysize = sizeof(((StatEntry *) 0)->queryid);
6267
info.entrysize = sizeof(StatEntry);
63-
stat_htab = ShmemInitHash("AQO Stat HTAB", fs_max_items, fs_max_items,
68+
stat_htab = ShmemInitHash("AQO Stat HTAB", fs_max_items,
6469
&info, HASH_ELEM | HASH_BLOBS);
6570

6671
/* Init shared memory table for query texts */
6772
info.keysize = sizeof(((QueryTextEntry *) 0)->queryid);
6873
info.entrysize = sizeof(QueryTextEntry);
69-
qtexts_htab = ShmemInitHash("AQO Query Texts HTAB", fs_max_items, fs_max_items,
74+
qtexts_htab = ShmemInitHash("AQO Query Texts HTAB", fs_max_items,
7075
&info, HASH_ELEM | HASH_BLOBS);
7176

7277
/* Shared memory hash table for the data */
7378
info.keysize = sizeof(data_key);
7479
info.entrysize = sizeof(DataEntry);
75-
data_htab = ShmemInitHash("AQO Data HTAB", fss_max_items, fss_max_items,
80+
data_htab = ShmemInitHash("AQO Data HTAB", fss_max_items,
7681
&info, HASH_ELEM | HASH_BLOBS);
7782

7883
/* Shared memory hash table for queries */
7984
info.keysize = sizeof(((QueriesEntry *) 0)->queryid);
8085
info.entrysize = sizeof(QueriesEntry);
81-
queries_htab = ShmemInitHash("AQO Queries HTAB", fs_max_items, fs_max_items,
86+
queries_htab = ShmemInitHash("AQO Queries HTAB", fs_max_items,
8287
&info, HASH_ELEM | HASH_BLOBS);
8388

8489
LWLockRelease(AddinShmemInitLock);
85-
LWLockRegisterTranche(aqo_state->lock.tranche, "AQO");
86-
LWLockRegisterTranche(aqo_state->stat_lock.tranche, "AQO Stat Lock Tranche");
87-
LWLockRegisterTranche(aqo_state->qtexts_lock.tranche, "AQO QTexts Lock Tranche");
88-
LWLockRegisterTranche(aqo_state->qtext_trancheid, "AQO Query Texts Tranche");
89-
LWLockRegisterTranche(aqo_state->data_lock.tranche, "AQO Data Lock Tranche");
90-
LWLockRegisterTranche(aqo_state->queries_lock.tranche, "AQO Queries Lock Tranche");
9190

9291
if (!IsUnderPostmaster && !found)
9392
{

path_utils.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -393,10 +393,6 @@ get_path_clauses(Path *path, PlannerInfo *root, List **selectivities)
393393
return get_path_clauses(((GroupPath *) path)->subpath, root,
394394
selectivities);
395395
break;
396-
case T_UpperUniquePath:
397-
return get_path_clauses(((UpperUniquePath *) path)->subpath, root,
398-
selectivities);
399-
break;
400396
case T_AggPath:
401397
return get_path_clauses(((AggPath *) path)->subpath, root,
402398
selectivities);

postprocessing.c

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -543,12 +543,11 @@ learnOnPlanState(PlanState *p, void *context)
543543
/*
544544
* Set up flags to store cardinality statistics.
545545
*/
546-
bool
546+
void
547547
aqo_ExecutorStart(QueryDesc *queryDesc, int eflags)
548548
{
549549
instr_time now;
550550
bool use_aqo;
551-
bool plan_valid;
552551

553552
/*
554553
* If the plan pulled from a plan cache, planning don't needed. Restore
@@ -597,14 +596,12 @@ aqo_ExecutorStart(QueryDesc *queryDesc, int eflags)
597596
}
598597

599598
if (prev_ExecutorStart_hook)
600-
plan_valid = prev_ExecutorStart_hook(queryDesc, eflags);
599+
prev_ExecutorStart_hook(queryDesc, eflags);
601600
else
602-
plan_valid = standard_ExecutorStart(queryDesc, eflags);
601+
standard_ExecutorStart(queryDesc, eflags);
603602

604603
if (use_aqo)
605604
StorePlanInternals(queryDesc);
606-
607-
return plan_valid;
608605
}
609606

610607
#include "utils/timeout.h"
@@ -1009,7 +1006,7 @@ print_node_explain(ExplainState *es, PlanState *ps, Plan *plan)
10091006

10101007
for (i = 0; i < ps->worker_instrument->num_workers; i++)
10111008
{
1012-
Instrumentation *instrument = &ps->worker_instrument->instrument[i];
1009+
NodeInstrumentation *instrument = &ps->worker_instrument->instrument[i];
10131010

10141011
if (instrument->nloops <= 0)
10151012
continue;

preprocessing.c

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -82,18 +82,21 @@ static PlannedStmt *
8282
call_default_planner(Query *parse,
8383
const char *query_string,
8484
int cursorOptions,
85-
ParamListInfo boundParams)
85+
ParamListInfo boundParams,
86+
ExplainState *es)
8687
{
8788
if (prev_planner_hook)
8889
return prev_planner_hook(parse,
8990
query_string,
9091
cursorOptions,
91-
boundParams);
92+
boundParams,
93+
es);
9294
else
9395
return standard_planner(parse,
9496
query_string,
9597
cursorOptions,
96-
boundParams);
98+
boundParams,
99+
es);
97100
}
98101

99102
/*
@@ -123,7 +126,8 @@ PlannedStmt *
123126
aqo_planner(Query *parse,
124127
const char *query_string,
125128
int cursorOptions,
126-
ParamListInfo boundParams)
129+
ParamListInfo boundParams,
130+
ExplainState *es)
127131
{
128132
bool query_is_stored = false;
129133
MemoryContext oldctx;
@@ -149,7 +153,8 @@ aqo_planner(Query *parse,
149153
return call_default_planner(parse,
150154
query_string,
151155
cursorOptions,
152-
boundParams);
156+
boundParams,
157+
es);
153158
}
154159

155160
selectivity_cache_clear();
@@ -178,7 +183,8 @@ aqo_planner(Query *parse,
178183
return call_default_planner(parse,
179184
query_string,
180185
cursorOptions,
181-
boundParams);
186+
boundParams,
187+
es);
182188
}
183189

184190
elog(DEBUG1, "AQO will be used for query '%s', class "UINT64_FORMAT,
@@ -347,7 +353,7 @@ aqo_planner(Query *parse,
347353
PlannedStmt *stmt;
348354

349355
stmt = call_default_planner(parse, query_string,
350-
cursorOptions, boundParams);
356+
cursorOptions, boundParams, es);
351357

352358
/* Release the memory, allocated for AQO predictions */
353359
MemoryContextReset(AQOPredictMemCtx);

preprocessing.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
extern PlannedStmt *aqo_planner(Query *parse,
77
const char *query_string,
88
int cursorOptions,
9-
ParamListInfo boundParams);
9+
ParamListInfo boundParams,
10+
struct ExplainState *es);
1011
extern void disable_aqo_for_query(void);
1112

1213
#endif /* __PREPROCESSING_H__ */

storage.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
#include "funcapi.h"
2323
#include "miscadmin.h"
2424
#include "pgstat.h"
25+
#include "storage/fd.h"
26+
#include "utils/tuplestore.h"
2527

2628
#include "aqo.h"
2729
#include "aqo_shared.h"

0 commit comments

Comments
 (0)