MCPcopy Create free account
hub / github.com/apache/cloudberry / show_buffer_usage

Function show_buffer_usage

src/backend/commands/explain.c:4533–4664  ·  view source on GitHub ↗

* Show buffer usage details. */

Source from the content-addressed store, hash-verified

4531 * Show buffer usage details.
4532 */
4533static void
4534show_buffer_usage(ExplainState *es, const BufferUsage *usage, bool planning)
4535{
4536 if (es->format == EXPLAIN_FORMAT_TEXT)
4537 {
4538 bool has_shared = (usage->shared_blks_hit > 0 ||
4539 usage->shared_blks_read > 0 ||
4540 usage->shared_blks_dirtied > 0 ||
4541 usage->shared_blks_written > 0);
4542 bool has_local = (usage->local_blks_hit > 0 ||
4543 usage->local_blks_read > 0 ||
4544 usage->local_blks_dirtied > 0 ||
4545 usage->local_blks_written > 0);
4546 bool has_temp = (usage->temp_blks_read > 0 ||
4547 usage->temp_blks_written > 0);
4548 bool has_timing = (!INSTR_TIME_IS_ZERO(usage->blk_read_time) ||
4549 !INSTR_TIME_IS_ZERO(usage->blk_write_time));
4550 bool show_planning = (planning && (has_shared ||
4551 has_local || has_temp || has_timing));
4552
4553 if (show_planning)
4554 {
4555 ExplainIndentText(es);
4556 appendStringInfoString(es->str, "Planning:\n");
4557 es->indent++;
4558 }
4559
4560 /* Show only positive counter values. */
4561 if (has_shared || has_local || has_temp)
4562 {
4563 ExplainIndentText(es);
4564 appendStringInfoString(es->str, "Buffers:");
4565
4566 if (has_shared)
4567 {
4568 appendStringInfoString(es->str, " shared");
4569 if (usage->shared_blks_hit > 0)
4570 appendStringInfo(es->str, " hit=%lld",
4571 (long long) usage->shared_blks_hit);
4572 if (usage->shared_blks_read > 0)
4573 appendStringInfo(es->str, " read=%lld",
4574 (long long) usage->shared_blks_read);
4575 if (usage->shared_blks_dirtied > 0)
4576 appendStringInfo(es->str, " dirtied=%lld",
4577 (long long) usage->shared_blks_dirtied);
4578 if (usage->shared_blks_written > 0)
4579 appendStringInfo(es->str, " written=%lld",
4580 (long long) usage->shared_blks_written);
4581 if (has_local || has_temp)
4582 appendStringInfoChar(es->str, ',');
4583 }
4584 if (has_local)
4585 {
4586 appendStringInfoString(es->str, " local");
4587 if (usage->local_blks_hit > 0)
4588 appendStringInfo(es->str, " hit=%lld",
4589 (long long) usage->local_blks_hit);
4590 if (usage->local_blks_read > 0)

Callers 2

ExplainOnePlanFunction · 0.85
ExplainNodeFunction · 0.85

Calls 6

ExplainIndentTextFunction · 0.85
appendStringInfoStringFunction · 0.85
appendStringInfoFunction · 0.85
appendStringInfoCharFunction · 0.85
ExplainPropertyIntegerFunction · 0.85
ExplainPropertyFloatFunction · 0.85

Tested by

no test coverage detected