Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit4b234fd

Browse files
committed
Fix inappropriate printing of never-measured times in EXPLAIN.
EXPLAIN (ANALYZE, TIMING OFF) would print an elapsed time of zero fora trigger function, because no measurement has been taken but it printedthe field anyway. This isn't what EXPLAIN does elsewhere, so suppress it.In the same vein, EXPLAIN (ANALYZE, BUFFERS) with non-text output formatwould print buffer I/O timing numbers even when no measurement has beentaken because track_io_timing is off. That seems not per policy, either,so change it.Back-patch to 9.2 where these features were introduced.Maksim MilyutinDiscussion: <081c0540-ecaa-bd29-3fd2-6358f3b359a9@postgrespro.ru>
1 parente05f6f7 commit4b234fd

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

‎src/backend/commands/explain.c

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
#include"optimizer/planmain.h"
2828
#include"parser/parsetree.h"
2929
#include"rewrite/rewriteHandler.h"
30+
#include"storage/bufmgr.h"
3031
#include"tcop/tcopprot.h"
3132
#include"utils/builtins.h"
3233
#include"utils/json.h"
@@ -698,16 +699,20 @@ report_triggers(ResultRelInfo *rInfo, bool show_relname, ExplainState *es)
698699
appendStringInfo(es->str," for constraint %s",conname);
699700
if (show_relname)
700701
appendStringInfo(es->str," on %s",relname);
701-
appendStringInfo(es->str,": time=%.3f calls=%.0f\n",
702-
1000.0*instr->total,instr->ntuples);
702+
if (es->timing)
703+
appendStringInfo(es->str,": time=%.3f calls=%.0f\n",
704+
1000.0*instr->total,instr->ntuples);
705+
else
706+
appendStringInfo(es->str,": calls=%.0f\n",instr->ntuples);
703707
}
704708
else
705709
{
706710
ExplainPropertyText("Trigger Name",trig->tgname,es);
707711
if (conname)
708712
ExplainPropertyText("Constraint Name",conname,es);
709713
ExplainPropertyText("Relation",relname,es);
710-
ExplainPropertyFloat("Time",1000.0*instr->total,3,es);
714+
if (es->timing)
715+
ExplainPropertyFloat("Time",1000.0*instr->total,3,es);
711716
ExplainPropertyFloat("Calls",instr->ntuples,0,es);
712717
}
713718

@@ -2429,8 +2434,11 @@ show_buffer_usage(ExplainState *es, const BufferUsage *usage)
24292434
ExplainPropertyLong("Local Written Blocks",usage->local_blks_written,es);
24302435
ExplainPropertyLong("Temp Read Blocks",usage->temp_blks_read,es);
24312436
ExplainPropertyLong("Temp Written Blocks",usage->temp_blks_written,es);
2432-
ExplainPropertyFloat("I/O Read Time",INSTR_TIME_GET_MILLISEC(usage->blk_read_time),3,es);
2433-
ExplainPropertyFloat("I/O Write Time",INSTR_TIME_GET_MILLISEC(usage->blk_write_time),3,es);
2437+
if (track_io_timing)
2438+
{
2439+
ExplainPropertyFloat("I/O Read Time",INSTR_TIME_GET_MILLISEC(usage->blk_read_time),3,es);
2440+
ExplainPropertyFloat("I/O Write Time",INSTR_TIME_GET_MILLISEC(usage->blk_write_time),3,es);
2441+
}
24342442
}
24352443
}
24362444

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp