473,396 Members | 1,816 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Log_statement behaviour a little misleading?

This caught me today :

I switched on "log_statement=true" whilst examining a possible foreign
key concurrency problem. I noticed that the generated foreign key check

"SELECT 1 FROM ONLY ... WHERE id = ...FOR UPDATE..."

on the parent table seemed to be only appearing every now and again.
This caused some scratching of the head :-)

Finally light dawned (ok - after reading ri_triggers.c and querying
pg_locks) - that the backend saves the execution plan for the generated
statement, so it is only planned once...and I guess log_statement is
triggered in the plan stage somewhere...

So setting "log_statement=true" does all *statements* - but not all
*executions* of each statement. Is this the intention?

(BTW - I am using 7.4.1)
best wishes

Mark
---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?

http://archives.postgresql.org

Nov 22 '05 #1
3 2663
Mark Kirkwood <ma****@paradise.net.nz> writes:
So setting "log_statement=true" does all *statements* - but not all
*executions* of each statement. Is this the intention?


AFAIK this is an implementation artifact that's never really been
discussed. Another aspect of the artifact is that SQL commands
appearing in plpgsql functions will be logged only on first execution
in a session.

I think you could make a fair argument that "log_statement" ought to log
only commands received from the client application. There would be real
value in being able to trace execution of plpgsql functions, but such a
feature would have very little to do with log_statement as it now
stands. The fact that RI triggers issue SQL commands is an artifact of
their implementation (and one that I believe Stephan and Jan would like
to get rid of); they shouldn't be cluttering the log at all.

At least that's what it seems like to me after a few moments'
reflection. Other opinions out there?

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddressHere" to ma*******@postgresql.org)

Nov 22 '05 #2
Tom Lane wrote:

The fact that RI triggers issue SQL commands is an artifact of
their implementation (and one that I believe Stephan and Jan would like
to get rid of); they shouldn't be cluttering the log at all.

I am glad you mentioned that - I did find myself wondering why it was
necessary to go through the whole parse->plan->etc business, when the
backend "knows" that an access via the (required) primary key is going
to be available...

cheers

Mark


---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faqs/FAQ.html

Nov 22 '05 #3
Tom Lane wrote:
Mark Kirkwood <ma****@paradise.net.nz> writes:
So setting "log_statement=true" does all *statements* - but not all
*executions* of each statement. Is this the intention?


AFAIK this is an implementation artifact that's never really been
discussed. Another aspect of the artifact is that SQL commands
appearing in plpgsql functions will be logged only on first execution
in a session.

I think you could make a fair argument that "log_statement" ought to log
only commands received from the client application. There would be real
value in being able to trace execution of plpgsql functions, but such a
feature would have very little to do with log_statement as it now
stands. The fact that RI triggers issue SQL commands is an artifact of
their implementation (and one that I believe Stephan and Jan would like
to get rid of); they shouldn't be cluttering the log at all.

At least that's what it seems like to me after a few moments'
reflection. Other opinions out there?


I checked prepared queries and it looks like this:

LOG: statement: prepare xx as select 1;
LOG: statement: execute xx;

which seems OK by me. I have updated the docs to mention the behavior
mentioned above for PREPARE and PL/pgSQL.

--
Bruce Momjian | http://candle.pha.pa.us
pg***@candle.pha.pa.us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073

Index: doc/src/sgml/runtime.sgml
================================================== =================
RCS file: /cvsroot/pgsql-server/doc/src/sgml/runtime.sgml,v
retrieving revision 1.232
diff -c -c -r1.232 runtime.sgml
*** doc/src/sgml/runtime.sgml 23 Jan 2004 23:54:20 -0000 1.232
--- doc/src/sgml/runtime.sgml 25 Jan 2004 00:32:55 -0000
***************
*** 1822,1829 ****
<listitem>
<para>
Causes each SQL statement to be logged. The default is off.
! Only superusers can turn off this option if it is enabled by
! the administrator.
</para>
</listitem>
</varlistentry>
--- 1822,1832 ----
<listitem>
<para>
Causes each SQL statement to be logged. The default is off.
! <command>EXECUTE</> only displays the plan name, not the
! prepared query. Server-side languages like
! <application>PL/pgSQL</> that store functions in a cache only
! display their queries on first function call. superusers can
! turn off this option if it is enabled by the administrator.
</para>
</listitem>
</varlistentry>
---------------------------(end of broadcast)---------------------------
TIP 9: the planner will ignore your desire to choose an index scan if your
joining column's datatypes do not match

Nov 22 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

36
by: Dmitriy Iassenev | last post by:
hi, I found an interesting thing in operator behaviour in C++ : int i=1; printf("%d",i++ + i++); I think the value of the expression "i++ + i++" _must_ be 3, but all the compilers I tested...
18
by: Philipp Lenssen | last post by:
I want to write a third installment of "Little Known HTML Facts"*. I would appreciate your input here. For one thing, I would like to remember what exactly those proprietary icons were you could...
25
by: Nitin Bhardwaj | last post by:
Well, i'm a relatively new into C( strictly speaking : well i'm a student and have been doing & studying C programming for the last 4 years).....and also a regular reader of "comp.lang.c" I...
31
by: DeltaOne | last post by:
#include<stdio.h> typedef struct test{ int i; int j; }test; main(){ test var; var.i=10; var.j=20;
33
by: Lalatendu Das | last post by:
Dear friends, I am getting a problem in the code while interacting with a nested Do-while loop It is skipping a scanf () function which it should not. I have written the whole code below. Please...
8
by: Claudio Grondi | last post by:
Here an example of what I mean (Python 2.4.2, IDLE 1.1.2, Windows XP SP2, NTFS file system, 80 GByte large file): Traceback (most recent call last): File "<pyshell#1>", line 1, in -toplevel-...
5
by: jkn | last post by:
Hi all Python 2.4.2 (#1, Apr 26 2006, 23:35:31) on linux2 Type "help", "copyright", "credits" or "license" for more information. Traceback (most recent call last): File "<stdin>", line 1, in...
2
by: =?Utf-8?B?R1ROMTcwNzc3?= | last post by:
Hi Guys, I'm using dreamweavers login behaviour to log people in, I've managed to manipulate it a little as I have many sites using the same database, but I'd like to manipulate it a little...
173
by: Ron Ford | last post by:
I'm looking for a freeware c99 compiler for windows. I had intended to use MS's Visual C++ Express and use its C capability. In the past with my MS products, I've simply needed to make .c the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.