explain change
This commit is contained in:
parent
bf6fdeebb5
commit
765dd2a4c0
@ -7,7 +7,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/commands/explain.c,v 1.6 1996/12/29 00:53:20 momjian Exp $
|
* $Header: /cvsroot/pgsql/src/backend/commands/explain.c,v 1.7 1996/12/29 19:30:55 momjian Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -27,8 +27,8 @@
|
|||||||
|
|
||||||
typedef struct ExplainState {
|
typedef struct ExplainState {
|
||||||
/* options */
|
/* options */
|
||||||
int printCost; /* print cost */
|
bool printCost; /* print cost */
|
||||||
int printNodes; /* do nodeToString() instead */
|
bool printNodes; /* do nodeToString() instead */
|
||||||
/* other states */
|
/* other states */
|
||||||
List *rtable; /* range table */
|
List *rtable; /* range table */
|
||||||
} ExplainState;
|
} ExplainState;
|
||||||
@ -69,18 +69,25 @@ ExplainQuery(Query *query, List *options, CommandDest dest)
|
|||||||
memset(es, 0, sizeof(ExplainState));
|
memset(es, 0, sizeof(ExplainState));
|
||||||
|
|
||||||
/* parse options */
|
/* parse options */
|
||||||
es->printCost = 1; /* default */
|
|
||||||
while (options) {
|
while (options) {
|
||||||
char *ostr = strVal(lfirst(options));
|
char *ostr = strVal(lfirst(options));
|
||||||
if (!strcasecmp(ostr, "cost"))
|
if (!strcasecmp(ostr, "cost"))
|
||||||
es->printCost = 1;
|
es->printCost = true;
|
||||||
else if (!strcasecmp(ostr, "full"))
|
else if (!strcasecmp(ostr, "plan"))
|
||||||
es->printNodes = 1;
|
es->printNodes = true;
|
||||||
|
else if (!strcasecmp(ostr, "full")) {
|
||||||
|
es->printCost = true;
|
||||||
|
es->printNodes = true;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
elog(WARN, "Unknown EXPLAIN option: %s", ostr);
|
elog(WARN, "Unknown EXPLAIN option: %s", ostr);
|
||||||
|
|
||||||
options = lnext(options);
|
options = lnext(options);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!es->printCost && !es->printNodes)
|
||||||
|
es->printCost = true; /* default */
|
||||||
|
|
||||||
es->rtable = query->rtable;
|
es->rtable = query->rtable;
|
||||||
|
|
||||||
if (es->printNodes)
|
if (es->printNodes)
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
*
|
*
|
||||||
* Copyright (c) 1994, Regents of the University of California
|
* Copyright (c) 1994, Regents of the University of California
|
||||||
*
|
*
|
||||||
* $Id: psqlHelp.h,v 1.8 1996/12/29 00:53:59 momjian Exp $
|
* $Id: psqlHelp.h,v 1.9 1996/12/29 19:31:06 momjian Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -124,7 +124,7 @@ static struct _helpStruct QL_HELP[] = {
|
|||||||
"end [transaction];"},
|
"end [transaction];"},
|
||||||
{ "explain",
|
{ "explain",
|
||||||
"explain the query execution plan",
|
"explain the query execution plan",
|
||||||
"explain [with {cost|full}] <query>"},
|
"explain [with {cost|plan|full}] <query>"},
|
||||||
{ "fetch",
|
{ "fetch",
|
||||||
"retrieve tuples from a cursor",
|
"retrieve tuples from a cursor",
|
||||||
"fetch [forward|backward] [<number>|all] [in <cursorname>];"},
|
"fetch [forward|backward] [<number>|all] [in <cursorname>];"},
|
||||||
|
@ -1,14 +1,17 @@
|
|||||||
.\" This is -*-nroff-*-
|
.\" This is -*-nroff-*-
|
||||||
.\" XXX standard disclaimer belongs here....
|
.\" XXX standard disclaimer belongs here....
|
||||||
.\" $Header: /cvsroot/pgsql/src/man/Attic/explain.l,v 1.2 1996/12/29 03:55:36 momjian Exp $
|
.\" $Header: /cvsroot/pgsql/src/man/Attic/explain.l,v 1.3 1996/12/29 19:31:16 momjian Exp $
|
||||||
.TH EXPLAIN SQL 11/05/95 PostgreSQL PostgreSQL
|
.TH EXPLAIN SQL 11/05/95 PostgreSQL PostgreSQL
|
||||||
.SH NAME
|
.SH NAME
|
||||||
explain \(em explains statement execution details
|
explain \(em explains statement execution details
|
||||||
.SH SYNOPSIS
|
.SH SYNOPSIS
|
||||||
.nf
|
.nf
|
||||||
\fBexplain [with\fP \fB{cost|full}]\fR query
|
\fBexplain [with\fP \fB{cost|plan|full}]\fR query
|
||||||
.fi
|
.fi
|
||||||
.SH DESCRIPTION
|
.SH DESCRIPTION
|
||||||
This command outputs details about the supplied query. The default
|
This command outputs details about the supplied query. The default
|
||||||
output is the computed query cost. \f2full\f1 displays a full query plan
|
output is the computed query cost. \f2plan\f1 displays the full query
|
||||||
and cost.
|
plan. \f2full\f1 display both query plan and query cost.
|
||||||
|
.PP
|
||||||
|
The query cost and plan can be affected by running vacuum.
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user