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
b33a7322
Commit
b33a7322
authored
Oct 18, 2005
by
Tom Lane
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve trace_sort code to also show the total memory or disk space used.
Per request from Marc.
parent
48f3d778
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
39 additions
and
6 deletions
+39
-6
src/backend/utils/sort/logtape.c
src/backend/utils/sort/logtape.c
+10
-1
src/backend/utils/sort/tuplesort.c
src/backend/utils/sort/tuplesort.c
+27
-4
src/include/utils/logtape.h
src/include/utils/logtape.h
+2
-1
No files found.
src/backend/utils/sort/logtape.c
View file @
b33a7322
...
...
@@ -64,7 +64,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/utils/sort/logtape.c,v 1.1
6 2005/10/15 02:49:37 momjian
Exp $
* $PostgreSQL: pgsql/src/backend/utils/sort/logtape.c,v 1.1
7 2005/10/18 22:59:37 tgl
Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -925,3 +925,12 @@ LogicalTapeTell(LogicalTapeSet *lts, int tapenum,
*
blocknum
=
lt
->
curBlockNumber
;
*
offset
=
lt
->
pos
;
}
/*
* Obtain total disk space currently used by a LogicalTapeSet, in blocks.
*/
long
LogicalTapeSetBlocks
(
LogicalTapeSet
*
lts
)
{
return
lts
->
nFileBlocks
;
}
src/backend/utils/sort/tuplesort.c
View file @
b33a7322
...
...
@@ -78,7 +78,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/utils/sort/tuplesort.c,v 1.5
2 2005/10/15 02:49:37 momjian
Exp $
* $PostgreSQL: pgsql/src/backend/utils/sort/tuplesort.c,v 1.5
3 2005/10/18 22:59:37 tgl
Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -134,6 +134,7 @@ struct Tuplesortstate
TupSortStatus
status
;
/* enumerated value as shown above */
bool
randomAccess
;
/* did caller request random access? */
long
availMem
;
/* remaining memory available, in bytes */
long
allowedMem
;
/* total memory allowed, in bytes */
LogicalTapeSet
*
tapeset
;
/* logtape.c object for tapes in a temp file */
/*
...
...
@@ -433,7 +434,8 @@ tuplesort_begin_common(int workMem, bool randomAccess)
state
->
status
=
TSS_INITIAL
;
state
->
randomAccess
=
randomAccess
;
state
->
availMem
=
workMem
*
1024L
;
state
->
allowedMem
=
workMem
*
1024L
;
state
->
availMem
=
state
->
allowedMem
;
state
->
tapeset
=
NULL
;
state
->
memtupcount
=
0
;
...
...
@@ -582,9 +584,24 @@ void
tuplesort_end
(
Tuplesortstate
*
state
)
{
int
i
;
#ifdef TRACE_SORT
long
spaceUsed
;
#endif
if
(
state
->
tapeset
)
{
#ifdef TRACE_SORT
spaceUsed
=
LogicalTapeSetBlocks
(
state
->
tapeset
);
#endif
LogicalTapeSetClose
(
state
->
tapeset
);
}
else
{
#ifdef TRACE_SORT
spaceUsed
=
(
state
->
allowedMem
-
state
->
availMem
+
1023
)
/
1024
;
#endif
}
if
(
state
->
memtuples
)
{
for
(
i
=
0
;
i
<
state
->
memtupcount
;
i
++
)
...
...
@@ -604,8 +621,14 @@ tuplesort_end(Tuplesortstate *state)
#ifdef TRACE_SORT
if
(
trace_sort
)
elog
(
NOTICE
,
"sort ended: %s"
,
pg_rusage_show
(
&
state
->
ru_start
));
{
if
(
state
->
tapeset
)
elog
(
NOTICE
,
"external sort ended, %ld disk blocks used: %s"
,
spaceUsed
,
pg_rusage_show
(
&
state
->
ru_start
));
else
elog
(
NOTICE
,
"internal sort ended, %ld KB used: %s"
,
spaceUsed
,
pg_rusage_show
(
&
state
->
ru_start
));
}
#endif
pfree
(
state
);
...
...
src/include/utils/logtape.h
View file @
b33a7322
...
...
@@ -8,7 +8,7 @@
* Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $PostgreSQL: pgsql/src/include/utils/logtape.h,v 1.1
2 2004/12/31 22:03:46 pgsq
l Exp $
* $PostgreSQL: pgsql/src/include/utils/logtape.h,v 1.1
3 2005/10/18 22:59:37 tg
l Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -38,5 +38,6 @@ extern bool LogicalTapeSeek(LogicalTapeSet *lts, int tapenum,
long
blocknum
,
int
offset
);
extern
void
LogicalTapeTell
(
LogicalTapeSet
*
lts
,
int
tapenum
,
long
*
blocknum
,
int
*
offset
);
extern
long
LogicalTapeSetBlocks
(
LogicalTapeSet
*
lts
);
#endif
/* LOGTAPE_H */
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