From blind@xythos.com Wed Aug 17 04:42:37 2005 X-Original-To: pgsql-jdbc-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 4624252927; Wed, 17 Aug 2005 01:42:37 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 26067-01; Wed, 17 Aug 2005 04:42:33 +0000 (GMT) Received: from NSNOVPS00411.nacio.xythos.com (212-59.84.64.master-link.com [64.84.59.212]) by svr1.postgresql.org (Postfix) with ESMTP id 55B6552897; Wed, 17 Aug 2005 01:42:30 -0300 (ADT) X-MimeOLE: Produced By Microsoft Exchange V6.0.6487.1 Content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----_=_NextPart_001_01C5A2E6.133B18A8" Subject: Performance problem using V3 protocol in jdbc driver Date: Tue, 16 Aug 2005 21:42:29 -0700 Message-ID: <03E7D3E231BB7B4A915A6581D4296CC6015D534E@NSNOVPS00411.nacio.xythos.com> X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: Performance problem using V3 protocol in jdbc driver Thread-Index: AcWi5hZNs712lLDwQT+PcpWjcgBCsQ== From: "Barry Lind" To: Cc: X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.074 required=5 tests=[AWL=-0.004, FORGED_RCVD_HELO=0.05, HTML_60_70=0.027, HTML_MESSAGE=0.001] X-Spam-Level: X-Archive-Number: 200508/108 X-Sequence-Number: 13677 This is a multi-part message in MIME format. ------_=_NextPart_001_01C5A2E6.133B18A8 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable We just moved a large production instance of ours from Oracle to Postgres 8.0.3 on linux. When running on Oracle the machine hummed along using about 5% of the CPU easily handling the fairly constant load, after moving the data to Postgres the machine was pretty much maxed out on CPU and could no longer keep up with the transaction volume. On a hunch I switched the jdbc driver to using the V2 protocol and the load on the machine dropped down to what it was when using Oracle and everything was fine. =20 Now obviously I have found a work around for the performance problem, but I really don't want to rely on using the V2 protocol forever, and don't want to have to recommend to our customers that they need to run with the V2 protocol. So I would like to resolve the problem and be able to move back to a default configuration with the V3 protocol and the benefits thereof. =20 The problem is that I don't really know where to begin to debug a problem like this. In development environments and testing environments we have not seen performance problems with the V3 protocol in the jdbc driver. But they don't come close to approaching the transaction volume of this production instance. =20 What I see when running the V3 protocol under 'top' is that the postgres processes are routinely using 15% or more of the CPU each, when running the V2 protocol they use more like 0.3%. =20 Does anyone have any suggestions on an approach to debug a problem like this? =20 Thanks, --Barry ------_=_NextPart_001_01C5A2E6.133B18A8 Content-Type: text/html; charset="us-ascii" Content-Transfer-Encoding: quoted-printable

We just moved a large production instance of ours = from Oracle to Postgres 8.0.3 on linux.  When running on Oracle the = machine hummed along using about 5% of the CPU easily handling the fairly = constant load, after moving the data to Postgres the machine was pretty much maxed out = on CPU and could no longer keep up with the transaction volume.  On a = hunch I switched the jdbc driver to using the V2 protocol and the load on the = machine dropped down to what it was when using Oracle and everything was = fine.

 

Now obviously I have found a work around for the = performance problem, but I really don’t want to rely on using the V2 protocol forever, and don’t want to have to recommend to our customers that = they need to run with the V2 protocol.  So I would like to resolve the = problem and be able to move back to a default configuration with the V3 protocol = and the benefits thereof.

 

The problem is that I don’t really know where = to begin to debug a problem like this.  In development environments and = testing environments we have not seen performance problems with the V3 protocol = in the jdbc driver.  But they don’t come close to approaching the transaction volume of this production = instance.

 

What I see when running the V3 protocol under = ‘top’ is that the postgres processes are routinely using 15% or more of the = CPU each, when running the V2 protocol they use more like = 0.3%.

 

Does anyone have any suggestions on an approach to = debug a problem like this?

 

Thanks,

--Barry

------_=_NextPart_001_01C5A2E6.133B18A8-- From tgl@sss.pgh.pa.us Wed Aug 17 05:01:53 2005 X-Original-To: pgsql-jdbc-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 43575529DA; Wed, 17 Aug 2005 02:01:53 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 32118-03; Wed, 17 Aug 2005 05:01:48 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id 1C195529C6; Wed, 17 Aug 2005 02:01:45 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j7H51j41012038; Wed, 17 Aug 2005 01:01:45 -0400 (EDT) To: "Barry Lind" Cc: pgsql-performance@postgresql.org, pgsql-jdbc@postgresql.org Subject: Re: Performance problem using V3 protocol in jdbc driver In-reply-to: <03E7D3E231BB7B4A915A6581D4296CC6015D534E@NSNOVPS00411.nacio.xythos.com> References: <03E7D3E231BB7B4A915A6581D4296CC6015D534E@NSNOVPS00411.nacio.xythos.com> Comments: In-reply-to "Barry Lind" message dated "Tue, 16 Aug 2005 21:42:29 -0700" Date: Wed, 17 Aug 2005 01:01:45 -0400 Message-ID: <12037.1124254905@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.006 required=5 tests=[AWL=0.006] X-Spam-Level: X-Archive-Number: 200508/109 X-Sequence-Number: 13678 "Barry Lind" writes: > ... On a hunch I switched the jdbc driver to using the V2 protocol > and the load on the machine dropped down to what it was when using > Oracle and everything was fine. First knee-jerk reaction is that it's an optimization problem stemming from V3 protocol feeding parameterized queries to the backend where V2 did not, and the planner being unable to cope :-( Can you identify the specific queries causing the problem? regards, tom lane From blind@xythos.com Wed Aug 17 05:43:45 2005 X-Original-To: pgsql-jdbc-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 8161D529EC; Wed, 17 Aug 2005 02:43:45 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 36727-09; Wed, 17 Aug 2005 05:43:43 +0000 (GMT) Received: from NSNOVPS00411.nacio.xythos.com (212-59.84.64.master-link.com [64.84.59.212]) by svr1.postgresql.org (Postfix) with ESMTP id 275EF529D6; Wed, 17 Aug 2005 02:43:40 -0300 (ADT) X-MimeOLE: Produced By Microsoft Exchange V6.0.6487.1 Content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Subject: Re: Performance problem using V3 protocol in jdbc driver Date: Tue, 16 Aug 2005 22:43:40 -0700 Message-ID: <03E7D3E231BB7B4A915A6581D4296CC6015D5352@NSNOVPS00411.nacio.xythos.com> X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: [JDBC] Performance problem using V3 protocol in jdbc driver Thread-Index: AcWi6MdL6nw11NNHQ9q4dDVy3dz7XQAA4nBw From: "Barry Lind" To: "Tom Lane" Cc: , X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.061 required=5 tests=[AWL=0.011, FORGED_RCVD_HELO=0.05] X-Spam-Level: X-Archive-Number: 200508/110 X-Sequence-Number: 13679 That was my suspicion as well, which is why I tried the V2 protocol. =20 I do not know of any specific queries that are causing the problem. As I monitor 'top' I see processes utilizing a significant amount of CPU running SELECT, UPDATE and DELETE, which would lead me to believe that it isn't any one specific query. How does one identify on a live system specific queries that are running slow, especially with the V3 protocol and when the system is executing about a 100 queries a second (which makes turning on any sort of logging very very verbose)? (I just subscribed to the performance list, so this is probably something that has been answered many times before on this list). I haven't tried to track down a performance problem like this before on postgres. Since most of our large customers run Oracle that is where I have the knowledge to figure something like this out. Thanks, --Barry -----Original Message----- From: Tom Lane [mailto:tgl@sss.pgh.pa.us]=20 Sent: Tuesday, August 16, 2005 10:02 PM To: Barry Lind Cc: pgsql-performance@postgresql.org; pgsql-jdbc@postgresql.org Subject: Re: [JDBC] Performance problem using V3 protocol in jdbc driver "Barry Lind" writes: > ... On a hunch I switched the jdbc driver to using the V2 protocol > and the load on the machine dropped down to what it was when using > Oracle and everything was fine. First knee-jerk reaction is that it's an optimization problem stemming from V3 protocol feeding parameterized queries to the backend where V2 did not, and the planner being unable to cope :-( Can you identify the specific queries causing the problem? regards, tom lane From mudfoot@rawbw.com Wed Aug 17 08:14:26 2005 X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id CA54652B1E for ; Wed, 17 Aug 2005 05:14:26 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 91460-05 for ; Wed, 17 Aug 2005 08:14:25 +0000 (GMT) Received: from mail0.rawbw.com (mail0.rawbw.com [198.144.192.41]) by svr1.postgresql.org (Postfix) with ESMTP id BC77452B38 for ; Wed, 17 Aug 2005 05:14:23 -0300 (ADT) Received: (from www@localhost) by mail0.rawbw.com (8.11.6p2/8.11.6) id j7H8EPA52792 for pgsql-performance@postgresql.org; Wed, 17 Aug 2005 01:14:25 -0700 (PDT) Received: from 198.144.203.173 ([198.144.203.173]) by webmail.rawbw.com (IMP) with HTTP for ; Wed, 17 Aug 2005 01:14:24 -0700 Message-ID: <1124266464.4302f1e0d5d30@webmail.rawbw.com> Date: Wed, 17 Aug 2005 01:14:24 -0700 From: mudfoot@rawbw.com To: pgsql-performance@postgresql.org Subject: Re: Performance problem using V3 protocol in jdbc driver References: <03E7D3E231BB7B4A915A6581D4296CC6015D534E@NSNOVPS00411.nacio.xythos.com> In-Reply-To: <03E7D3E231BB7B4A915A6581D4296CC6015D534E@NSNOVPS00411.nacio.xythos.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit User-Agent: Internet Messaging Program (IMP) 3.2.1 X-Originating-IP: 198.144.203.173 X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.178 required=5 tests=[NO_REAL_NAME=0.178] X-Spam-Level: X-Archive-Number: 200508/199 X-Sequence-Number: 13946 Quoting Barry Lind : > > > What I see when running the V3 protocol under 'top' is that the postgres > processes are routinely using 15% or more of the CPU each, when running > the V2 protocol they use more like 0.3%. > > > > Does anyone have any suggestions on an approach to debug a problem like > this? > > Tracing system calls is a good starting point--truss on Solaris, strace on Linux (Redhat anyway), ktrace on BSD. The difference between 0.3% and 15% CPU utilization under similar load will very likely (though not with complete certainty) be showing very noticeably different system call activity. If you notice a difference in system call activity, then that would probably provide a hint as to what's going on--where the inefficiency lies. It's possible to spin the CPU up without any system calls, but system call tracing can be done pretty quickly and you should be able to see any interesting patterns emerge quite quickly. ^ | This method is a good starting point for troubleshooting just about any funny process activity. And it comes with the added benefit of not having to know ahead of time about the specific matter at hand (JDBC implementation, in this case). :-) That's having your cake and eating it, too. > > Thanks, > > --Barry > > From nagy@ecircle-ag.com Wed Aug 17 09:30:56 2005 X-Original-To: pgsql-jdbc-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 5D3EB52A43; Wed, 17 Aug 2005 06:30:56 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 20237-07; Wed, 17 Aug 2005 09:30:53 +0000 (GMT) Received: from mail.ecircle.de (mail.ecircle.de [195.140.186.200]) by svr1.postgresql.org (Postfix) with ESMTP id D0C8E529E6; Wed, 17 Aug 2005 06:30:51 -0300 (ADT) Received: from [192.168.1.110] (unknown [192.168.1.110]) by mail.ecircle.de (READY) with ESMTP id CE0FF120567; Wed, 17 Aug 2005 11:30:51 +0200 (CEST) Subject: Re: Performance problem using V3 protocol in jdbc driver From: Csaba Nagy To: Barry Lind Cc: pgsql-performance@postgresql.org, Postgres JDBC In-Reply-To: <03E7D3E231BB7B4A915A6581D4296CC6015D534E@NSNOVPS00411.nacio.xythos.com> References: <03E7D3E231BB7B4A915A6581D4296CC6015D534E@NSNOVPS00411.nacio.xythos.com> Content-Type: text/plain; charset=UTF-8 Message-Id: <1124271051.24337.56.camel@coppola.muc.ecircle.de> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.6 (1.4.6-2) Date: Wed, 17 Aug 2005 11:30:51 +0200 Content-Transfer-Encoding: 8bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.011 required=5 tests=[AWL=0.011] X-Spam-Level: X-Archive-Number: 200508/111 X-Sequence-Number: 13680 Barry, I have made a similar experience, moving a big Oracle data base to Postgres 8.03 on linux. The first impact was similar, huge performance problems. The main problem was bad planner choices. The cause in our case: bad parameter types in the jdbc set methods (I guess you use Java). For oracle we used the NUMERIC type to set primary keys, but the postgres id type used was BIGINT, and it just refused to use the index in this case. Imagine that kicking in on a 100 million rows table... a sequential scan started a few times a second, now that made the DB unusable. So we fixed the code that for oracle continues to use NUMERIC and for postgres it uses BIGINT, and that is very important on setNull calls too. One very useful tool was the following query: prepare ps as SELECT procpid, substring(current_query for 97), to_char((now()-query_start), 'HH24:MI:SS') as t FROM pg_stat_activity where current_query not like '% We just moved a large production instance of ours from Oracle to > Postgres 8.0.3 on linux. When running on Oracle the machine hummed > along using about 5% of the CPU easily handling the fairly constant > load, after moving the data to Postgres the machine was pretty much > maxed out on CPU and could no longer keep up with the transaction > volume. On a hunch I switched the jdbc driver to using the V2 > protocol and the load on the machine dropped down to what it was when > using Oracle and everything was fine. > > > > Now obviously I have found a work around for the performance problem, > but I really don’t want to rely on using the V2 protocol forever, and > don’t want to have to recommend to our customers that they need to run > with the V2 protocol. So I would like to resolve the problem and be > able to move back to a default configuration with the V3 protocol and > the benefits thereof. > > > > The problem is that I don’t really know where to begin to debug a > problem like this. In development environments and testing > environments we have not seen performance problems with the V3 > protocol in the jdbc driver. But they don’t come close to approaching > the transaction volume of this production instance. > > > > What I see when running the V3 protocol under ‘top’ is that the > postgres processes are routinely using 15% or more of the CPU each, > when running the V2 protocol they use more like 0.3%. > > > > Does anyone have any suggestions on an approach to debug a problem > like this? > > > > Thanks, > > --Barry > > From pg@fastcrypt.com Wed Aug 17 12:59:33 2005 X-Original-To: pgsql-jdbc-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 4DA06529DA for ; Wed, 17 Aug 2005 09:59:33 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 76722-10 for ; Wed, 17 Aug 2005 12:59:30 +0000 (GMT) Received: from net2.micro-automation.com (net2.micro-automation.com [64.7.141.29]) by svr1.postgresql.org (Postfix) with SMTP id 1F1F3528DB for ; Wed, 17 Aug 2005 09:59:28 -0300 (ADT) Received: (qmail 9823 invoked from network); 17 Aug 2005 12:59:32 -0000 Received: from dcdsl.ebox.com (HELO ?192.168.1.2?) (davec@64.7.143.116) by net2.micro-automation.com with SMTP; 17 Aug 2005 12:59:32 -0000 In-Reply-To: <03E7D3E231BB7B4A915A6581D4296CC6015D5352@NSNOVPS00411.nacio.xythos.com> References: <03E7D3E231BB7B4A915A6581D4296CC6015D5352@NSNOVPS00411.nacio.xythos.com> Mime-Version: 1.0 (Apple Message framework v733) Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed Message-Id: <76FC392F-3B3D-409E-A790-1D15B784C03E@fastcrypt.com> Cc: "Tom Lane" , , Content-Transfer-Encoding: 7bit From: Dave Cramer Subject: Re: [PERFORM] Performance problem using V3 protocol in jdbc driver Date: Wed, 17 Aug 2005 08:59:30 -0400 To: Barry Lind X-Mailer: Apple Mail (2.733) X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.013 required=5 tests=[AWL=0.013] X-Spam-Level: X-Archive-Number: 200508/114 X-Sequence-Number: 13683 Barry, One way to do this is to turn logging on for calls over a certain duration log_duration in the config file. This will only log calls over n milliseconds. There's a tool called iron eye SQL that monitors JDBC calls. http://www.irongrid.com/ unfortunately I am getting DNS errors from that site right now. I do have a copy of their code if you need it. Dave On 17-Aug-05, at 1:43 AM, Barry Lind wrote: > That was my suspicion as well, which is why I tried the V2 protocol. > > I do not know of any specific queries that are causing the > problem. As > I monitor 'top' I see processes utilizing a significant amount of CPU > running SELECT, UPDATE and DELETE, which would lead me to believe that > it isn't any one specific query. > > How does one identify on a live system specific queries that are > running > slow, especially with the V3 protocol and when the system is executing > about a 100 queries a second (which makes turning on any sort of > logging > very very verbose)? (I just subscribed to the performance list, so > this > is probably something that has been answered many times before on this > list). > > I haven't tried to track down a performance problem like this > before on > postgres. Since most of our large customers run Oracle that is > where I > have the knowledge to figure something like this out. > > Thanks, > --Barry > > > -----Original Message----- > From: Tom Lane [mailto:tgl@sss.pgh.pa.us] > Sent: Tuesday, August 16, 2005 10:02 PM > To: Barry Lind > Cc: pgsql-performance@postgresql.org; pgsql-jdbc@postgresql.org > Subject: Re: [JDBC] Performance problem using V3 protocol in jdbc > driver > > > "Barry Lind" writes: > >> ... On a hunch I switched the jdbc driver to using the V2 protocol >> and the load on the machine dropped down to what it was when using >> Oracle and everything was fine. >> > > First knee-jerk reaction is that it's an optimization problem stemming > from V3 protocol feeding parameterized queries to the backend where V2 > did not, and the planner being unable to cope :-( > > Can you identify the specific queries causing the problem? > > regards, tom lane > > > ---------------------------(end of > broadcast)--------------------------- > TIP 3: Have you checked our extensive FAQ? > > http://www.postgresql.org/docs/faq > >