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

Commit27cb626

Browse files
committed
revert to showing buffer counts in explain (buffers)
1 parent215cbc9 commit27cb626

File tree

1 file changed

+25
-74
lines changed

1 file changed

+25
-74
lines changed

‎src/backend/commands/explain.c

Lines changed: 25 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Portions Copyright (c) 1994-5, Regents of the University of California
88
*
99
* IDENTIFICATION
10-
* $PostgreSQL: pgsql/src/backend/commands/explain.c,v 1.201 2010/02/15 02:36:26 stark Exp $
10+
* $PostgreSQL: pgsql/src/backend/commands/explain.c,v 1.202 2010/02/16 20:07:13 stark Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -98,7 +98,7 @@ static void ExplainJSONLineEnding(ExplainState *es);
9898
staticvoidExplainYAMLLineStarting(ExplainState*es);
9999
staticvoidescape_json(StringInfobuf,constchar*str);
100100
staticvoidescape_yaml(StringInfobuf,constchar*str);
101-
staticdoublenormalize_memory(doubleamount,char**unit,int*precision);
101+
102102

103103

104104
/*
@@ -1082,63 +1082,47 @@ ExplainNode(Plan *plan, PlanState *planstate,
10821082
if (has_shared||has_local||has_temp)
10831083
{
10841084
appendStringInfoSpaces(es->str,es->indent*2);
1085-
appendStringInfoString(es->str,"Total Buffer Usage:");
1085+
appendStringInfoString(es->str,"Buffers:");
10861086

10871087
if (has_shared)
10881088
{
1089-
char*hit_unit,*read_unit,*written_unit;
1090-
inthit_prec,read_prec,written_prec;
1091-
doublehit_mem=normalize_memory((double)usage->shared_blks_hit*BLCKSZ,&hit_unit,&hit_prec);
1092-
doubleread_mem=normalize_memory((double)usage->shared_blks_read*BLCKSZ,&read_unit,&read_prec);
1093-
doublewritten_mem=normalize_memory((double)usage->shared_blks_written*BLCKSZ,&written_unit,&written_prec);
1094-
10951089
appendStringInfoString(es->str," shared");
1096-
appendStringInfo(es->str," hit=%.*f%s",
1097-
hit_prec,hit_mem,hit_unit);
1090+
if (usage->shared_blks_hit>0)
1091+
appendStringInfo(es->str," hit=%ld",
1092+
usage->shared_blks_hit);
10981093
if (usage->shared_blks_read>0)
1099-
appendStringInfo(es->str," read=%.*f%s",
1100-
read_prec,read_mem,read_unit);
1094+
appendStringInfo(es->str," read=%ld",
1095+
usage->shared_blks_read);
11011096
if (usage->shared_blks_written>0)
1102-
appendStringInfo(es->str," written=%.*f%s",
1103-
written_prec,written_mem,written_unit);
1097+
appendStringInfo(es->str," written=%ld",
1098+
usage->shared_blks_written);
11041099
if (has_local||has_temp)
11051100
appendStringInfoChar(es->str,',');
11061101
}
11071102
if (has_local)
11081103
{
1109-
char*hit_unit,*read_unit,*written_unit;
1110-
inthit_prec,read_prec,written_prec;
1111-
doublehit_mem=normalize_memory((double)usage->local_blks_hit*BLCKSZ,&hit_unit,&hit_prec);
1112-
doubleread_mem=normalize_memory((double)usage->local_blks_read*BLCKSZ,&read_unit,&read_prec);
1113-
doublewritten_mem=normalize_memory((double)usage->local_blks_written*BLCKSZ,&written_unit,&written_prec);
1114-
1115-
appendStringInfoString(es->str," local");
1116-
if (usage->local_blks_hit>0)
1117-
appendStringInfo(es->str," hit=%.*f%s",
1118-
hit_prec,hit_mem,hit_unit);
1119-
if (usage->local_blks_read>0)
1120-
appendStringInfo(es->str," read=%.*f%s",
1121-
read_prec,read_mem,read_unit);
1122-
if (usage->local_blks_written>0)
1123-
appendStringInfo(es->str," written=%.*f%s",
1124-
written_prec,written_mem,written_unit);
1104+
appendStringInfoString(es->str," local");
1105+
if (usage->local_blks_hit>0)
1106+
appendStringInfo(es->str," hit=%ld",
1107+
usage->local_blks_hit);
1108+
if (usage->local_blks_read>0)
1109+
appendStringInfo(es->str," read=%ld",
1110+
usage->local_blks_read);
1111+
if (usage->local_blks_written>0)
1112+
appendStringInfo(es->str," written=%ld",
1113+
usage->local_blks_written);
11251114
if (has_temp)
11261115
appendStringInfoChar(es->str,',');
11271116
}
11281117
if (has_temp)
11291118
{
1130-
char*read_unit,*written_unit;
1131-
intread_prec,written_prec;
1132-
doubleread_mem=normalize_memory((double)usage->temp_blks_read*BLCKSZ,&read_unit,&read_prec);
1133-
doublewritten_mem=normalize_memory((double)usage->temp_blks_written*BLCKSZ,&written_unit,&written_prec);
1134-
11351119
appendStringInfoString(es->str," temp");
11361120
if (usage->temp_blks_read>0)
1137-
appendStringInfo(es->str," read=%.*f%s",
1138-
read_prec,read_mem,read_unit);
1139-
if (usage->temp_blks_written>0)
1140-
appendStringInfo(es->str," written=%.*f%s",
1141-
written_prec,written_mem,written_unit);
1121+
appendStringInfo(es->str," read=%ld",
1122+
usage->temp_blks_read);
1123+
if (usage->temp_blks_written>0)
1124+
appendStringInfo(es->str," written=%ld",
1125+
usage->temp_blks_written);
11421126
}
11431127
appendStringInfoChar(es->str,'\n');
11441128
}
@@ -2170,36 +2154,3 @@ escape_yaml(StringInfo buf, const char *str)
21702154

21712155
appendStringInfo(buf,"%s",str);
21722156
}
2173-
2174-
/*
2175-
* For a quantity of bytes pick a reasonable display unit for it and
2176-
* return the quantity in that unit. Also return the unit name and a
2177-
* reasonable precision via the reference parameters.
2178-
*/
2179-
2180-
staticdoublenormalize_memory(doubleamount,char**unit,int*precision)
2181-
{
2182-
staticchar*units[]= {"bytes","kB","MB","GB","TB","PB"};
2183-
char**u=units,**last=units+ (sizeof(units)/sizeof(*units)-1);
2184-
2185-
while (amount>1024.0&&u<last)
2186-
{
2187-
amount /=1024.0;
2188-
u+=1;
2189-
}
2190-
2191-
*unit=*u;
2192-
2193-
/* if it's bytes or kB then don't print decimals since that's less
2194-
* than blocksize, otherwise always print 3 significant digits */
2195-
if (u==units||u==units+1 )
2196-
*precision=0;
2197-
elseif (amount<10)
2198-
*precision=2;
2199-
elseif (amount<100)
2200-
*precision=1;
2201-
else
2202-
*precision=0;
2203-
2204-
returnamount;
2205-
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp