Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Greenplum
Gpdb
提交
b952d61c
G
Gpdb
项目概览
Greenplum
/
Gpdb
通知
7
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
Gpdb
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
b952d61c
编写于
6月 11, 2003
作者:
B
Bruce Momjian
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add log_min_duration_statement.
Christopher Kings-Lynne
上级
8bfe93c5
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
66 addition
and
14 deletion
+66
-14
doc/src/sgml/runtime.sgml
doc/src/sgml/runtime.sgml
+18
-1
src/backend/tcop/postgres.c
src/backend/tcop/postgres.c
+31
-10
src/backend/utils/misc/guc.c
src/backend/utils/misc/guc.c
+8
-1
src/backend/utils/misc/postgresql.conf.sample
src/backend/utils/misc/postgresql.conf.sample
+4
-0
src/bin/psql/tab-complete.c
src/bin/psql/tab-complete.c
+2
-1
src/include/utils/guc.h
src/include/utils/guc.h
+3
-1
未找到文件。
doc/src/sgml/runtime.sgml
浏览文件 @
b952d61c
<!--
$Header: /cvsroot/pgsql/doc/src/sgml/runtime.sgml,v 1.18
2 2003/05/27 17:49:45
momjian Exp $
$Header: /cvsroot/pgsql/doc/src/sgml/runtime.sgml,v 1.18
3 2003/06/11 18:01:13
momjian Exp $
-->
<Chapter Id="runtime">
...
...
@@ -1051,6 +1051,23 @@ SET ENABLE_SEQSCAN TO OFF;
</listitem>
</varlistentry>
<varlistentry>
<term><varname>LOG_MIN_DURATION_STATEMENT</varname> (<type>integer</type>)</term>
<listitem>
<para>
Sets a minimum statement execution time (in milliseconds)
above which a statement will be logged. All SQL statements
that run longer than the time specified will be logged together
with the duration, in seconds. The default is <literal>0</literal>
(turning this feature off). For example, if you set it
to <literal>250</literal> then all SQL statements that run longer
than 250ms will be logged along with the duration. Enabling this
option can be useful in tracking down unoptimized queries in
your applications.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><varname>LOG_MIN_ERROR_STATEMENT</varname> (<type>string</type>)</term>
<listitem>
...
...
src/backend/tcop/postgres.c
浏览文件 @
b952d61c
...
...
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/tcop/postgres.c,v 1.34
6 2003/05/27 17:49:46
momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/tcop/postgres.c,v 1.34
7 2003/06/11 18:01:14
momjian Exp $
*
* NOTES
* this is the "main" module of the postgres backend and
...
...
@@ -663,6 +663,7 @@ exec_simple_query(const char *query_string)
struct
timeval
start_t
,
stop_t
;
bool
save_log_duration
=
log_duration
;
int
save_log_min_duration_statement
=
log_min_duration_statement
;
bool
save_log_statement_stats
=
log_statement_stats
;
/*
...
...
@@ -673,11 +674,12 @@ exec_simple_query(const char *query_string)
pgstat_report_activity
(
query_string
);
/*
* We use save_log_duration so "SET log_duration = true" doesn't
* report incorrect time because gettimeofday() wasn't called.
* We use save_log_* so "SET log_duration = true" and
* "SET log_min_duration_statement = true" don't report incorrect
* time because gettimeofday() wasn't called.
* Similarly, log_statement_stats has to be captured once.
*/
if
(
save_log_duration
)
if
(
save_log_duration
||
save_log_min_duration_statement
>
0
)
gettimeofday
(
&
start_t
,
NULL
);
if
(
save_log_statement_stats
)
...
...
@@ -915,19 +917,38 @@ exec_simple_query(const char *query_string)
QueryContext
=
NULL
;
/*
* Finish up monitoring.
* Combine processing here as we need to calculate the query
* duration in both instances.
*/
if
(
save_log_duration
)
if
(
save_log_duration
||
save_log_min_duration_statement
>
0
)
{
long
usecs
;
gettimeofday
(
&
stop_t
,
NULL
);
if
(
stop_t
.
tv_usec
<
start_t
.
tv_usec
)
{
stop_t
.
tv_sec
--
;
stop_t
.
tv_usec
+=
1000000
;
}
elog
(
LOG
,
"duration: %ld.%06ld sec"
,
(
long
)
(
stop_t
.
tv_sec
-
start_t
.
tv_sec
),
(
long
)
(
stop_t
.
tv_usec
-
start_t
.
tv_usec
));
usecs
=
(
long
)
(
stop_t
.
tv_sec
-
start_t
.
tv_sec
)
*
1000000
+
(
long
)
(
stop_t
.
tv_usec
-
start_t
.
tv_usec
);
/*
* Output a duration_query to the log if the query has exceeded the
* min duration.
*/
if
(
usecs
>=
save_log_min_duration_statement
*
1000
)
elog
(
LOG
,
"duration_statement: %ld.%06ld %s"
,
(
long
)
(
stop_t
.
tv_sec
-
start_t
.
tv_sec
),
(
long
)
(
stop_t
.
tv_usec
-
start_t
.
tv_usec
),
query_string
);
/*
* If the user is requesting logging of all durations, then log
* that as well.
*/
if
(
save_log_duration
)
elog
(
LOG
,
"duration: %ld.%06ld sec"
,
(
long
)
(
stop_t
.
tv_sec
-
start_t
.
tv_sec
),
(
long
)
(
stop_t
.
tv_usec
-
start_t
.
tv_usec
));
}
if
(
save_log_statement_stats
)
...
...
@@ -2526,7 +2547,7 @@ PostgresMain(int argc, char *argv[], const char *username)
if
(
!
IsUnderPostmaster
)
{
puts
(
"
\n
POSTGRES backend interactive interface "
);
puts
(
"$Revision: 1.34
6 $ $Date: 2003/05/27 17:49:46
$
\n
"
);
puts
(
"$Revision: 1.34
7 $ $Date: 2003/06/11 18:01:14
$
\n
"
);
}
/*
...
...
src/backend/utils/misc/guc.c
浏览文件 @
b952d61c
...
...
@@ -10,7 +10,7 @@
* Written by Peter Eisentraut <peter_e@gmx.net>.
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/misc/guc.c,v 1.12
8 2003/06/11 05:04:51
momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/misc/guc.c,v 1.12
9 2003/06/11 18:01:14
momjian Exp $
*
*--------------------------------------------------------------------
*/
...
...
@@ -55,6 +55,8 @@
#include "utils/pg_locale.h"
#include "pgstat.h"
int
log_min_duration_statement
=
0
;
#ifndef PG_KRB_SRVTAB
#define PG_KRB_SRVTAB ""
...
...
@@ -735,6 +737,11 @@ static struct config_int
0
,
-
15
,
2
,
NULL
,
NULL
},
{
{
"log_min_duration_statement"
,
PGC_USERSET
},
&
log_min_duration_statement
,
0
,
0
,
INT_MAX
/
1000
,
NULL
,
NULL
},
{
{
NULL
,
0
},
NULL
,
0
,
0
,
0
,
NULL
,
NULL
}
...
...
src/backend/utils/misc/postgresql.conf.sample
浏览文件 @
b952d61c
...
...
@@ -140,6 +140,10 @@
# debug5, debug4, debug3, debug2, debug1,
# info, notice, warning, error, panic(off)
#log_min_duration_statement = 0 # Log all statements whose
# execution time exceeds the value, in
# milliseconds. Zero disables.
#debug_print_parse = false
#debug_print_rewritten = false
#debug_print_plan = false
...
...
src/bin/psql/tab-complete.c
浏览文件 @
b952d61c
...
...
@@ -3,7 +3,7 @@
*
* Copyright 2000-2002 by PostgreSQL Global Development Group
*
* $Header: /cvsroot/pgsql/src/bin/psql/tab-complete.c,v 1.7
7 2003/05/14 03:26:02 tgl
Exp $
* $Header: /cvsroot/pgsql/src/bin/psql/tab-complete.c,v 1.7
8 2003/06/11 18:01:14 momjian
Exp $
*/
/*----------------------------------------------------------------------
...
...
@@ -538,6 +538,7 @@ psql_completion(char *text, int start, int end)
"lc_time"
,
"log_duration"
,
"log_executor_stats"
,
"log_min_duration_statement"
,
"log_min_error_statement"
,
"log_min_messages"
,
"log_parser_stats"
,
...
...
src/include/utils/guc.h
浏览文件 @
b952d61c
...
...
@@ -7,7 +7,7 @@
* Copyright 2000-2003 by PostgreSQL Global Development Group
* Written by Peter Eisentraut <peter_e@gmx.net>.
*
* $Id: guc.h,v 1.3
1 2003/05/06 20:26:28 tgl
Exp $
* $Id: guc.h,v 1.3
2 2003/06/11 18:01:14 momjian
Exp $
*--------------------------------------------------------------------
*/
#ifndef GUC_H
...
...
@@ -142,4 +142,6 @@ void write_nondefault_variables(GucContext context);
void
read_nondefault_variables
(
void
);
#endif
extern
int
log_min_duration_statement
;
#endif
/* GUC_H */
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录