|
7 | 7 | * Portions Copyright (c) 1994-5, Regents of the University of California |
8 | 8 | * |
9 | 9 | * 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 $ |
11 | 11 | * |
12 | 12 | *------------------------------------------------------------------------- |
13 | 13 | */ |
@@ -98,7 +98,7 @@ static void ExplainJSONLineEnding(ExplainState *es); |
98 | 98 | staticvoidExplainYAMLLineStarting(ExplainState*es); |
99 | 99 | staticvoidescape_json(StringInfobuf,constchar*str); |
100 | 100 | staticvoidescape_yaml(StringInfobuf,constchar*str); |
101 | | -staticdoublenormalize_memory(doubleamount,char**unit,int*precision); |
| 101 | + |
102 | 102 |
|
103 | 103 |
|
104 | 104 | /* |
@@ -1082,63 +1082,47 @@ ExplainNode(Plan *plan, PlanState *planstate, |
1082 | 1082 | if (has_shared||has_local||has_temp) |
1083 | 1083 | { |
1084 | 1084 | appendStringInfoSpaces(es->str,es->indent*2); |
1085 | | -appendStringInfoString(es->str,"Total Buffer Usage:"); |
| 1085 | +appendStringInfoString(es->str,"Buffers:"); |
1086 | 1086 |
|
1087 | 1087 | if (has_shared) |
1088 | 1088 | { |
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 | | - |
1095 | 1089 | 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); |
1098 | 1093 | 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); |
1101 | 1096 | 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); |
1104 | 1099 | if (has_local||has_temp) |
1105 | 1100 | appendStringInfoChar(es->str,','); |
1106 | 1101 | } |
1107 | 1102 | if (has_local) |
1108 | 1103 | { |
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); |
1125 | 1114 | if (has_temp) |
1126 | 1115 | appendStringInfoChar(es->str,','); |
1127 | 1116 | } |
1128 | 1117 | if (has_temp) |
1129 | 1118 | { |
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 | | - |
1135 | 1119 | appendStringInfoString(es->str," temp"); |
1136 | 1120 | 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); |
1142 | 1126 | } |
1143 | 1127 | appendStringInfoChar(es->str,'\n'); |
1144 | 1128 | } |
@@ -2170,36 +2154,3 @@ escape_yaml(StringInfo buf, const char *str) |
2170 | 2154 |
|
2171 | 2155 | appendStringInfo(buf,"%s",str); |
2172 | 2156 | } |
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 | | -} |