Skip to content
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

Set lsn fix v15 #252

Merged
merged 4 commits into from
Dec 8, 2022
Merged
Show file tree
Hide file tree
Changes from 2 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
2 changes: 2 additions & 0 deletions src/backend/access/heap/visibilitymap.c
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,9 @@ visibilitymap_set(Relation rel, BlockNumber heapBlk, Buffer heapBuf,
* If data checksums are enabled (or wal_log_hints=on), we
* need to protect the heap page from being torn.
*/
/* NEON: we have to update page LSN even if wal_log_hints=off
if (XLogHintBitIsNeeded())
*/
{
Page heapPage = BufferGetPage(heapBuf);

Expand Down
36 changes: 36 additions & 0 deletions src/backend/commands/explain.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ ExplainOneQuery_hook_type ExplainOneQuery_hook = NULL;
/* Hook for plugins to get control in explain_get_index_name() */
explain_get_index_name_hook_type explain_get_index_name_hook = NULL;

PrefetchStats prefetch_stats;

/* OR-able flags for ExplainXMLTag() */
#define X_OPENING 0
Expand Down Expand Up @@ -121,6 +122,7 @@ static void show_eval_params(Bitmapset *bms_params, ExplainState *es);
static const char *explain_get_index_name(Oid indexId);
static void show_buffer_usage(ExplainState *es, const BufferUsage *usage,
bool planning);
static void show_prefetch_info(ExplainState *es, const PrefetchStats* prefetch_info);
static void show_wal_usage(ExplainState *es, const WalUsage *usage);
static void ExplainIndexScanDetails(Oid indexid, ScanDirection indexorderdir,
ExplainState *es);
Expand Down Expand Up @@ -186,6 +188,8 @@ ExplainQuery(ParseState *pstate, ExplainStmt *stmt,
es->costs = defGetBoolean(opt);
else if (strcmp(opt->defname, "buffers") == 0)
es->buffers = defGetBoolean(opt);
else if (strcmp(opt->defname, "prefetch") == 0)
es->prefetch = defGetBoolean(opt);
else if (strcmp(opt->defname, "wal") == 0)
es->wal = defGetBoolean(opt);
else if (strcmp(opt->defname, "settings") == 0)
Expand Down Expand Up @@ -526,6 +530,7 @@ ExplainOnePlan(PlannedStmt *plannedstmt, IntoClause *into, ExplainState *es,
double totaltime = 0;
int eflags;
int instrument_option = 0;
PrefetchStats prefetch_before = prefetch_stats;

Assert(plannedstmt->commandType != CMD_UTILITY);

Expand Down Expand Up @@ -628,6 +633,16 @@ ExplainOnePlan(PlannedStmt *plannedstmt, IntoClause *into, ExplainState *es,
ExplainCloseGroup("Planning", "Planning", true, es);
}

if (es->prefetch)
{
PrefetchStats prefetch_elapsed;
prefetch_elapsed.hits = prefetch_stats.hits - prefetch_before.hits;
prefetch_elapsed.misses = prefetch_stats.misses - prefetch_before.misses;
ExplainOpenGroup("Prefetch", NULL, true, es);
show_prefetch_info(es, &prefetch_elapsed);
ExplainCloseGroup("Prefetch", NULL, true, es);
}

if (es->summary && planduration)
{
double plantime = INSTR_TIME_GET_DOUBLE(*planduration);
Expand Down Expand Up @@ -3501,6 +3516,27 @@ explain_get_index_name(Oid indexId)
return result;
}

/*
* Show prefetch statistics
*/
static void
show_prefetch_info(ExplainState *es, const PrefetchStats* prefetch_info)
{
if (es->format == EXPLAIN_FORMAT_TEXT)
{
ExplainIndentText(es);
appendStringInfo(es->str, "Prefetch: hits=%lld misses=%lld\n",
prefetch_info->hits, prefetch_info->misses);
}
else
{
ExplainPropertyInteger("Prefetch Hits", NULL,
prefetch_info->hits, es);
ExplainPropertyInteger("Prefetch Misses", NULL,
prefetch_info->misses, es);
}
}

/*
* Show buffer usage details.
*/
Expand Down
11 changes: 11 additions & 0 deletions src/include/commands/explain.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ typedef struct ExplainState
bool timing; /* print detailed node timing */
bool summary; /* print total planning and execution timing */
bool settings; /* print modified settings */
bool prefetch; /* print prefetch statistic */
ExplainFormat format; /* output format */
/* state for output formatting --- not reset for each new plan tree */
int indent; /* current indentation level */
Expand All @@ -61,6 +62,16 @@ typedef struct ExplainState
ExplainWorkersState *workers_state; /* needed if parallel plan */
} ExplainState;


/* Prefeth statistics */
typedef struct
{
long long unsigned hits;
long long unsigned misses;
} PrefetchStats;

extern PrefetchStats prefetch_stats;

/* Hook for plugins to get control in ExplainOneQuery() */
typedef void (*ExplainOneQuery_hook_type) (Query *query,
int cursorOptions,
Expand Down