Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit548d646

Browse files
committed
Add log_duration to GUC/postgresql.conf.
Rename debug_print_query to log_statement and rename show_query_stats toshow_statement_stats.
1 parentf4abdd8 commit548d646

File tree

7 files changed

+82
-32
lines changed

7 files changed

+82
-32
lines changed

‎doc/src/sgml/func.sgml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!--
2-
$Header: /cvsroot/pgsql/doc/src/sgml/func.sgml,v 1.118 2002/08/29 05:17:55 tgl Exp $
2+
$Header: /cvsroot/pgsql/doc/src/sgml/func.sgml,v 1.119 2002/09/01 23:26:05 momjian Exp $
33
PostgreSQL documentation
44
-->
55

@@ -5241,7 +5241,7 @@ select current_setting('DateStyle');
52415241
<literal>false</literal> instead. It is the equivalent to the SQL
52425242
<command>SET</command> command. For example:
52435243
<programlisting>
5244-
select set_config('show_query_stats','off','f');
5244+
select set_config('show_statement_stats','off','f');
52455245
set_config
52465246
------------
52475247
off

‎doc/src/sgml/runtime.sgml

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!--
2-
$Header: /cvsroot/pgsql/doc/src/sgml/runtime.sgml,v 1.131 2002/08/30 22:18:05 tgl Exp $
2+
$Header: /cvsroot/pgsql/doc/src/sgml/runtime.sgml,v 1.132 2002/09/01 23:26:06 momjian Exp $
33
-->
44

55
<Chapter Id="runtime">
@@ -928,7 +928,6 @@ env PGOPTIONS='-c geqo=off' psql
928928
</varlistentry>
929929

930930
<varlistentry>
931-
<term><varname>DEBUG_PRINT_QUERY</varname> (<type>boolean</type>)</term>
932931
<term><varname>DEBUG_PRINT_PARSE</varname> (<type>boolean</type>)</term>
933932
<term><varname>DEBUG_PRINT_REWRITTEN</varname> (<type>boolean</type>)</term>
934933
<term><varname>DEBUG_PRINT_PLAN</varname> (<type>boolean</type>)</term>
@@ -992,6 +991,26 @@ env PGOPTIONS='-c geqo=off' psql
992991
</listitem>
993992
</varlistentry>
994993

994+
<varlistentry>
995+
<term><varname>LOG_STATEMENT</varname> (<type>boolean</type>)</term>
996+
<listitem>
997+
<para>
998+
Prints each query received.
999+
</para>
1000+
</listitem>
1001+
</varlistentry>
1002+
1003+
<varlistentry>
1004+
<term><varname>LOG_DURATION</varname> (<type>boolean</type>)</term>
1005+
<listitem>
1006+
<para>
1007+
Prints the duration of every completed query. To use this option,
1008+
enable LOG_STATEMENT and LOG_PID so you can link the original query
1009+
to the duration using the process id.
1010+
</para>
1011+
</listitem>
1012+
</varlistentry>
1013+
9951014
<varlistentry>
9961015
<term><varname>LOG_TIMESTAMP</varname> (<type>boolean</type>)</term>
9971016
<listitem>
@@ -1003,7 +1022,7 @@ env PGOPTIONS='-c geqo=off' psql
10031022
</varlistentry>
10041023

10051024
<varlistentry>
1006-
<term><varname>SHOW_QUERY_STATS</varname> (<type>boolean</type>)</term>
1025+
<term><varname>SHOW_STATEMENT_STATS</varname> (<type>boolean</type>)</term>
10071026
<term><varname>SHOW_PARSER_STATS</varname> (<type>boolean</type>)</term>
10081027
<term><varname>SHOW_PLANNER_STATS</varname> (<type>boolean</type>)</term>
10091028
<term><varname>SHOW_EXECUTOR_STATS</varname> (<type>boolean</type>)</term>
@@ -2072,7 +2091,7 @@ dynamic_library_path = '/usr/local/lib/postgresql:/home/my_project/lib:$libdir'
20722091
</row>
20732092
<row>
20742093
<entry><option>-s</option></entry>
2075-
<entry><literal>show_query_stats = on</></entry>
2094+
<entry><literal>show_statement_stats = on</></entry>
20762095
<entry>*</entry>
20772096
</row>
20782097
<row>

‎src/backend/tcop/postgres.c

Lines changed: 34 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/tcop/postgres.c,v 1.287 2002/08/30 22:18:06tgl Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/tcop/postgres.c,v 1.288 2002/09/01 23:26:06momjian Exp $
1212
*
1313
* NOTES
1414
* this is the "main" module of the postgres backend and
@@ -220,7 +220,7 @@ InteractiveBackend(StringInfo inBuf)
220220
* if the query echo flag was given, print the query..
221221
*/
222222
if (EchoQuery)
223-
printf("query: %s\n",inBuf->data);
223+
printf("statement: %s\n",inBuf->data);
224224
fflush(stdout);
225225

226226
return'Q';
@@ -372,7 +372,7 @@ pg_parse_query(StringInfo query_string, Oid *typev, int nargs)
372372
{
373373
List*raw_parsetree_list;
374374

375-
if (Debug_print_query)
375+
if (Log_statement)
376376
elog(LOG,"query: %s",query_string->data);
377377

378378
if (Show_parser_stats)
@@ -561,9 +561,19 @@ pg_exec_query_string(StringInfo query_string,/* string to execute */
561561
MemoryContextoldcontext;
562562
List*parsetree_list,
563563
*parsetree_item;
564-
564+
structtimezonetz;
565+
structtimevalstart_t,stop_t;
566+
boolsave_Log_duration=Log_duration;
567+
565568
debug_query_string=query_string->data;/* used by pgmonitor */
566569

570+
/*
571+
*We use save_Log_duration so setting Log_duration to true doesn't
572+
* report incorrect time because gettimeofday() wasn't called.
573+
*/
574+
if (save_Log_duration)
575+
gettimeofday(&start_t,&tz);
576+
567577
/*
568578
* Start up a transaction command.All queries generated by the
569579
* query_string will be in this same command block, *unless* we find a
@@ -850,6 +860,19 @@ pg_exec_query_string(StringInfo query_string,/* string to execute */
850860
if (xact_started)
851861
finish_xact_command();
852862

863+
if (save_Log_duration)
864+
{
865+
gettimeofday(&stop_t,&tz);
866+
if (stop_t.tv_usec<start_t.tv_usec)
867+
{
868+
stop_t.tv_sec--;
869+
stop_t.tv_usec+=1000000;
870+
}
871+
elog(LOG,"duration: %ld.%06ld sec",
872+
(longint)stop_t.tv_sec-start_t.tv_sec,
873+
(longint)stop_t.tv_usec-start_t.tv_usec);
874+
}
875+
853876
debug_query_string=NULL;/* used by pgmonitor */
854877
}
855878

@@ -1234,7 +1257,7 @@ PostgresMain(int argc, char *argv[], const char *username)
12341257
if (atoi(optarg) >=1)
12351258
SetConfigOption("log_connections","true",ctx,gucsource);
12361259
if (atoi(optarg) >=2)
1237-
SetConfigOption("debug_print_query","true",ctx,gucsource);
1260+
SetConfigOption("log_statement","true",ctx,gucsource);
12381261
if (atoi(optarg) >=3)
12391262
SetConfigOption("debug_print_parse","true",ctx,gucsource);
12401263
if (atoi(optarg) >=4)
@@ -1377,7 +1400,7 @@ PostgresMain(int argc, char *argv[], const char *username)
13771400
/*
13781401
* s - report usage statistics (timings) after each query
13791402
*/
1380-
SetConfigOption("show_query_stats","true",ctx,gucsource);
1403+
SetConfigOption("show_statement_stats","true",ctx,gucsource);
13811404
break;
13821405

13831406
case't':
@@ -1489,11 +1512,11 @@ PostgresMain(int argc, char *argv[], const char *username)
14891512
/*
14901513
* Post-processing for command line options.
14911514
*/
1492-
if (Show_query_stats&&
1515+
if (Show_statement_stats&&
14931516
(Show_parser_stats||Show_planner_stats||Show_executor_stats))
14941517
{
14951518
elog(WARNING,"Query statistics are disabled because parser, planner, or executor statistics are on.");
1496-
SetConfigOption("show_query_stats","false",ctx,gucsource);
1519+
SetConfigOption("show_statement_stats","false",ctx,gucsource);
14971520
}
14981521

14991522
if (!IsUnderPostmaster)
@@ -1664,7 +1687,7 @@ PostgresMain(int argc, char *argv[], const char *username)
16641687
if (!IsUnderPostmaster)
16651688
{
16661689
puts("\nPOSTGRES backend interactive interface ");
1667-
puts("$Revision: 1.287 $ $Date: 2002/08/30 22:18:06 $\n");
1690+
puts("$Revision: 1.288 $ $Date: 2002/09/01 23:26:06 $\n");
16681691
}
16691692

16701693
/*
@@ -1887,7 +1910,7 @@ PostgresMain(int argc, char *argv[], const char *username)
18871910
* Note: transaction command start/end is now done within
18881911
* pg_exec_query_string(), not here.
18891912
*/
1890-
if (Show_query_stats)
1913+
if (Show_statement_stats)
18911914
ResetUsage();
18921915

18931916
pgstat_report_activity(parser_input->data);
@@ -1896,7 +1919,7 @@ PostgresMain(int argc, char *argv[], const char *username)
18961919
whereToSendOutput,
18971920
QueryContext);
18981921

1899-
if (Show_query_stats)
1922+
if (Show_statement_stats)
19001923
ShowUsage("QUERY STATISTICS");
19011924
}
19021925
break;

‎src/backend/utils/misc/guc.c

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* command, configuration file, and command line options.
66
* See src/backend/utils/misc/README for more information.
77
*
8-
* $Header: /cvsroot/pgsql/src/backend/utils/misc/guc.c,v 1.89 2002/08/30 22:18:07 tgl Exp $
8+
* $Header: /cvsroot/pgsql/src/backend/utils/misc/guc.c,v 1.90 2002/09/01 23:26:06 momjian Exp $
99
*
1010
* Copyright 2000 by PostgreSQL Global Development Group
1111
* Written by Peter Eisentraut <peter_e@gmx.net>.
@@ -77,7 +77,8 @@ static const char *assign_facility(const char *facility,
7777
#ifdefUSE_ASSERT_CHECKING
7878
boolassert_enabled= true;
7979
#endif
80-
boolDebug_print_query= false;
80+
boolLog_statement= false;
81+
boolLog_duration= false;
8182
boolDebug_print_plan= false;
8283
boolDebug_print_parse= false;
8384
boolDebug_print_rewritten= false;
@@ -86,7 +87,7 @@ boolDebug_pretty_print = false;
8687
boolShow_parser_stats= false;
8788
boolShow_planner_stats= false;
8889
boolShow_executor_stats= false;
89-
boolShow_query_stats= false;/* this is sort of all three above
90+
boolShow_statement_stats= false;/* this is sort of all three above
9091
* together */
9192
boolShow_btree_build_stats= false;
9293

@@ -362,7 +363,11 @@ static struct config_bool
362363
#endif
363364

364365
{
365-
{"debug_print_query",PGC_USERSET },&Debug_print_query,
366+
{"log_statement",PGC_USERSET },&Log_statement,
367+
false,NULL,NULL
368+
},
369+
{
370+
{"log_duration",PGC_USERSET },&Log_duration,
366371
false,NULL,NULL
367372
},
368373
{
@@ -395,7 +400,7 @@ static struct config_bool
395400
false,NULL,NULL
396401
},
397402
{
398-
{"show_query_stats",PGC_USERSET },&Show_query_stats,
403+
{"show_statement_stats",PGC_USERSET },&Show_statement_stats,
399404
false,NULL,NULL
400405
},
401406
#ifdefBTREE_BUILD_STATS

‎src/backend/utils/misc/postgresql.conf.sample

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@
102102
#geqo = true
103103
#geqo_selection_bias = 2.0# range 1.5-2.0
104104
#geqo_threshold = 11
105-
#geqo_pool_size = 0# default based on tables inquery,
105+
#geqo_pool_size = 0# default based on tables instatement,
106106
# range 128-1024
107107
#geqo_effort = 1
108108
#geqo_generations = 0
@@ -122,10 +122,11 @@
122122
#silent_mode = false
123123

124124
#log_connections = false
125-
#log_timestamp = false
126125
#log_pid = false
126+
#log_statement = false
127+
#log_duration = false
128+
#log_timestamp = false
127129

128-
#debug_print_query = false
129130
#debug_print_parse = false
130131
#debug_print_rewritten = false
131132
#debug_print_plan = false
@@ -151,7 +152,7 @@
151152
#show_parser_stats = false
152153
#show_planner_stats = false
153154
#show_executor_stats = false
154-
#show_query_stats = false
155+
#show_statement_stats = false
155156

156157
# requires BTREE_BUILD_STATS
157158
#show_btree_build_stats = false

‎src/bin/psql/tab-complete.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*
44
* Copyright 2000-2002 by PostgreSQL Global Development Group
55
*
6-
* $Header: /cvsroot/pgsql/src/bin/psql/tab-complete.c,v 1.60 2002/08/30 22:18:07 tgl Exp $
6+
* $Header: /cvsroot/pgsql/src/bin/psql/tab-complete.c,v 1.61 2002/09/01 23:26:06 momjian Exp $
77
*/
88

99
/*----------------------------------------------------------------------
@@ -231,15 +231,16 @@ psql_completion(char *text, int start, int end)
231231
"server_min_messages",
232232
"client_min_messages",
233233
"debug_assertions",
234-
"debug_print_query",
234+
"log_statement",
235+
"log_duration",
235236
"debug_print_parse",
236237
"debug_print_rewritten",
237238
"debug_print_plan",
238239
"debug_pretty_print",
239240
"show_parser_stats",
240241
"show_planner_stats",
241242
"show_executor_stats",
242-
"show_query_stats",
243+
"show_statement_stats",
243244
"trace_notify",
244245
"explain_pretty_print",
245246
"sql_inheritance",

‎src/include/utils/guc.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* External declarations pertaining to backend/utils/misc/guc.c and
55
* backend/utils/misc/guc-file.l
66
*
7-
* $Id: guc.h,v 1.20 2002/07/30 16:20:03 momjian Exp $
7+
* $Id: guc.h,v 1.21 2002/09/01 23:26:06 momjian Exp $
88
*/
99
#ifndefGUC_H
1010
#defineGUC_H
@@ -100,7 +100,8 @@ extern void ProcessGUCArray(ArrayType *array, GucSource source);
100100
externArrayType*GUCArrayAdd(ArrayType*array,constchar*name,constchar*value);
101101
externArrayType*GUCArrayDelete(ArrayType*array,constchar*name);
102102

103-
externboolDebug_print_query;
103+
externboolLog_statement;
104+
externboolLog_duration;
104105
externboolDebug_print_plan;
105106
externboolDebug_print_parse;
106107
externboolDebug_print_rewritten;
@@ -109,7 +110,7 @@ extern bool Debug_pretty_print;
109110
externboolShow_parser_stats;
110111
externboolShow_planner_stats;
111112
externboolShow_executor_stats;
112-
externboolShow_query_stats;
113+
externboolShow_statement_stats;
113114
externboolShow_btree_build_stats;
114115

115116
externboolExplain_pretty_print;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp