From: Bruce Momjian Date: Sun, 29 Dec 1996 19:31:16 +0000 (+0000) Subject: explain change X-Git-Tag: REL9_0_0~29510 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=765dd2a4c0376aad041aedfbf1aca8bf00bb6856;p=pg-rex%2Fsyncrep.git explain change --- diff --git a/src/backend/commands/explain.c b/src/backend/commands/explain.c index 5eabda8570..2dbc6938c3 100644 --- a/src/backend/commands/explain.c +++ b/src/backend/commands/explain.c @@ -7,7 +7,7 @@ * * * 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 { /* options */ - int printCost; /* print cost */ - int printNodes; /* do nodeToString() instead */ + bool printCost; /* print cost */ + bool printNodes; /* do nodeToString() instead */ /* other states */ List *rtable; /* range table */ } ExplainState; @@ -69,18 +69,25 @@ ExplainQuery(Query *query, List *options, CommandDest dest) memset(es, 0, sizeof(ExplainState)); /* parse options */ - es->printCost = 1; /* default */ while (options) { char *ostr = strVal(lfirst(options)); if (!strcasecmp(ostr, "cost")) - es->printCost = 1; - else if (!strcasecmp(ostr, "full")) - es->printNodes = 1; + es->printCost = true; + else if (!strcasecmp(ostr, "plan")) + es->printNodes = true; + else if (!strcasecmp(ostr, "full")) { + es->printCost = true; + es->printNodes = true; + } else elog(WARN, "Unknown EXPLAIN option: %s", ostr); options = lnext(options); } + + if (!es->printCost && !es->printNodes) + es->printCost = true; /* default */ + es->rtable = query->rtable; if (es->printNodes) diff --git a/src/bin/psql/psqlHelp.h b/src/bin/psql/psqlHelp.h index bf1f7f9b87..5fd6d11bf3 100644 --- a/src/bin/psql/psqlHelp.h +++ b/src/bin/psql/psqlHelp.h @@ -5,7 +5,7 @@ * * 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];"}, { "explain", "explain the query execution plan", - "explain [with {cost|full}] "}, + "explain [with {cost|plan|full}] "}, { "fetch", "retrieve tuples from a cursor", "fetch [forward|backward] [|all] [in ];"}, diff --git a/src/man/explain.l b/src/man/explain.l index 24eae095cb..317026e7bf 100644 --- a/src/man/explain.l +++ b/src/man/explain.l @@ -1,14 +1,17 @@ .\" This is -*-nroff-*- .\" 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 .SH NAME explain \(em explains statement execution details .SH SYNOPSIS .nf -\fBexplain [with\fP \fB{cost|full}]\fR query +\fBexplain [with\fP \fB{cost|plan|full}]\fR query .fi .SH DESCRIPTION This command outputs details about the supplied query. The default -output is the computed query cost. \f2full\f1 displays a full query plan -and cost. +output is the computed query cost. \f2plan\f1 displays the full query +plan. \f2full\f1 display both query plan and query cost. +.PP +The query cost and plan can be affected by running vacuum. +