Performance problem using V3 protocol in jdbc driver
Performance problem using V3 protocol in jdbc driver
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
Re: 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
Re: Performance problem using V3 protocol in jdbc driver
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
Re: Performance problem using V3 protocol in jdbc driver
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 > >
Re: [PERFORM] Performance problem using V3 protocol in jdbc driver
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 > >