Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
Postgres FD Implementation
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Abuhujair Javed
Postgres FD Implementation
Commits
27cb626f
Commit
27cb626f
authored
Feb 16, 2010
by
Greg Stark
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
revert to showing buffer counts in explain (buffers)
parent
215cbc90
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
74 deletions
+25
-74
src/backend/commands/explain.c
src/backend/commands/explain.c
+25
-74
No files found.
src/backend/commands/explain.c
View file @
27cb626f
...
@@ -7,7 +7,7 @@
...
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1994-5, Regents of the University of California
* Portions Copyright (c) 1994-5, Regents of the University of California
*
*
* IDENTIFICATION
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/commands/explain.c,v 1.20
1 2010/02/15 02:36:26
stark Exp $
* $PostgreSQL: pgsql/src/backend/commands/explain.c,v 1.20
2 2010/02/16 20:07:13
stark Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
...
@@ -98,7 +98,7 @@ static void ExplainJSONLineEnding(ExplainState *es);
...
@@ -98,7 +98,7 @@ static void ExplainJSONLineEnding(ExplainState *es);
static
void
ExplainYAMLLineStarting
(
ExplainState
*
es
);
static
void
ExplainYAMLLineStarting
(
ExplainState
*
es
);
static
void
escape_json
(
StringInfo
buf
,
const
char
*
str
);
static
void
escape_json
(
StringInfo
buf
,
const
char
*
str
);
static
void
escape_yaml
(
StringInfo
buf
,
const
char
*
str
);
static
void
escape_yaml
(
StringInfo
buf
,
const
char
*
str
);
static
double
normalize_memory
(
double
amount
,
char
**
unit
,
int
*
precision
);
/*
/*
...
@@ -1082,63 +1082,47 @@ ExplainNode(Plan *plan, PlanState *planstate,
...
@@ -1082,63 +1082,47 @@ ExplainNode(Plan *plan, PlanState *planstate,
if
(
has_shared
||
has_local
||
has_temp
)
if
(
has_shared
||
has_local
||
has_temp
)
{
{
appendStringInfoSpaces
(
es
->
str
,
es
->
indent
*
2
);
appendStringInfoSpaces
(
es
->
str
,
es
->
indent
*
2
);
appendStringInfoString
(
es
->
str
,
"
Total Buffer Usage
:"
);
appendStringInfoString
(
es
->
str
,
"
Buffers
:"
);
if
(
has_shared
)
if
(
has_shared
)
{
{
char
*
hit_unit
,
*
read_unit
,
*
written_unit
;
int
hit_prec
,
read_prec
,
written_prec
;
double
hit_mem
=
normalize_memory
((
double
)
usage
->
shared_blks_hit
*
BLCKSZ
,
&
hit_unit
,
&
hit_prec
);
double
read_mem
=
normalize_memory
((
double
)
usage
->
shared_blks_read
*
BLCKSZ
,
&
read_unit
,
&
read_prec
);
double
written_mem
=
normalize_memory
((
double
)
usage
->
shared_blks_written
*
BLCKSZ
,
&
written_unit
,
&
written_prec
);
appendStringInfoString
(
es
->
str
,
" shared"
);
appendStringInfoString
(
es
->
str
,
" shared"
);
appendStringInfo
(
es
->
str
,
" hit=%.*f%s"
,
if
(
usage
->
shared_blks_hit
>
0
)
hit_prec
,
hit_mem
,
hit_unit
);
appendStringInfo
(
es
->
str
,
" hit=%ld"
,
usage
->
shared_blks_hit
);
if
(
usage
->
shared_blks_read
>
0
)
if
(
usage
->
shared_blks_read
>
0
)
appendStringInfo
(
es
->
str
,
" read=%
.*f%s
"
,
appendStringInfo
(
es
->
str
,
" read=%
ld
"
,
read_prec
,
read_mem
,
read_unit
);
usage
->
shared_blks_read
);
if
(
usage
->
shared_blks_written
>
0
)
if
(
usage
->
shared_blks_written
>
0
)
appendStringInfo
(
es
->
str
,
" written=%
.*f%s
"
,
appendStringInfo
(
es
->
str
,
" written=%
ld
"
,
written_prec
,
written_mem
,
written_unit
);
usage
->
shared_blks_written
);
if
(
has_local
||
has_temp
)
if
(
has_local
||
has_temp
)
appendStringInfoChar
(
es
->
str
,
','
);
appendStringInfoChar
(
es
->
str
,
','
);
}
}
if
(
has_local
)
if
(
has_local
)
{
{
char
*
hit_unit
,
*
read_unit
,
*
written_unit
;
int
hit_prec
,
read_prec
,
written_prec
;
double
hit_mem
=
normalize_memory
((
double
)
usage
->
local_blks_hit
*
BLCKSZ
,
&
hit_unit
,
&
hit_prec
);
double
read_mem
=
normalize_memory
((
double
)
usage
->
local_blks_read
*
BLCKSZ
,
&
read_unit
,
&
read_prec
);
double
written_mem
=
normalize_memory
((
double
)
usage
->
local_blks_written
*
BLCKSZ
,
&
written_unit
,
&
written_prec
);
appendStringInfoString
(
es
->
str
,
" local"
);
appendStringInfoString
(
es
->
str
,
" local"
);
if
(
usage
->
local_blks_hit
>
0
)
if
(
usage
->
local_blks_hit
>
0
)
appendStringInfo
(
es
->
str
,
" hit=%
.*f%s"
,
appendStringInfo
(
es
->
str
,
" hit=%
ld"
,
hit_prec
,
hit_mem
,
hit_un
it
);
usage
->
local_blks_h
it
);
if
(
usage
->
local_blks_read
>
0
)
if
(
usage
->
local_blks_read
>
0
)
appendStringInfo
(
es
->
str
,
" read=%
.*f%s
"
,
appendStringInfo
(
es
->
str
,
" read=%
ld
"
,
read_prec
,
read_mem
,
read_unit
);
usage
->
local_blks_read
);
if
(
usage
->
local_blks_written
>
0
)
if
(
usage
->
local_blks_written
>
0
)
appendStringInfo
(
es
->
str
,
" written=%
.*f%s
"
,
appendStringInfo
(
es
->
str
,
" written=%
ld
"
,
written_prec
,
written_mem
,
written_unit
);
usage
->
local_blks_written
);
if
(
has_temp
)
if
(
has_temp
)
appendStringInfoChar
(
es
->
str
,
','
);
appendStringInfoChar
(
es
->
str
,
','
);
}
}
if
(
has_temp
)
if
(
has_temp
)
{
{
char
*
read_unit
,
*
written_unit
;
int
read_prec
,
written_prec
;
double
read_mem
=
normalize_memory
((
double
)
usage
->
temp_blks_read
*
BLCKSZ
,
&
read_unit
,
&
read_prec
);
double
written_mem
=
normalize_memory
((
double
)
usage
->
temp_blks_written
*
BLCKSZ
,
&
written_unit
,
&
written_prec
);
appendStringInfoString
(
es
->
str
,
" temp"
);
appendStringInfoString
(
es
->
str
,
" temp"
);
if
(
usage
->
temp_blks_read
>
0
)
if
(
usage
->
temp_blks_read
>
0
)
appendStringInfo
(
es
->
str
,
" read=%
.*f%s
"
,
appendStringInfo
(
es
->
str
,
" read=%
ld
"
,
read_prec
,
read_mem
,
read_unit
);
usage
->
temp_blks_read
);
if
(
usage
->
temp_blks_written
>
0
)
if
(
usage
->
temp_blks_written
>
0
)
appendStringInfo
(
es
->
str
,
" written=%
.*f%s
"
,
appendStringInfo
(
es
->
str
,
" written=%
ld
"
,
written_prec
,
written_mem
,
written_unit
);
usage
->
temp_blks_written
);
}
}
appendStringInfoChar
(
es
->
str
,
'\n'
);
appendStringInfoChar
(
es
->
str
,
'\n'
);
}
}
...
@@ -2170,36 +2154,3 @@ escape_yaml(StringInfo buf, const char *str)
...
@@ -2170,36 +2154,3 @@ escape_yaml(StringInfo buf, const char *str)
appendStringInfo
(
buf
,
"%s"
,
str
);
appendStringInfo
(
buf
,
"%s"
,
str
);
}
}
/*
* For a quantity of bytes pick a reasonable display unit for it and
* return the quantity in that unit. Also return the unit name and a
* reasonable precision via the reference parameters.
*/
static
double
normalize_memory
(
double
amount
,
char
**
unit
,
int
*
precision
)
{
static
char
*
units
[]
=
{
"bytes"
,
"kB"
,
"MB"
,
"GB"
,
"TB"
,
"PB"
};
char
**
u
=
units
,
**
last
=
units
+
(
sizeof
(
units
)
/
sizeof
(
*
units
)
-
1
);
while
(
amount
>
1024
.
0
&&
u
<
last
)
{
amount
/=
1024
.
0
;
u
+=
1
;
}
*
unit
=
*
u
;
/* if it's bytes or kB then don't print decimals since that's less
* than blocksize, otherwise always print 3 significant digits */
if
(
u
==
units
||
u
==
units
+
1
)
*
precision
=
0
;
else
if
(
amount
<
10
)
*
precision
=
2
;
else
if
(
amount
<
100
)
*
precision
=
1
;
else
*
precision
=
0
;
return
amount
;
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment