Performance problem using V3 protocol in jdbc driver

Поиск
Список
Период
Сортировка
Искать

Performance problem using V3 protocol in jdbc driver

От:
"Barry Lind" <blind@xythos.com>
Дата:

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

От:
Tom Lane <tgl@sss.pgh.pa.us>
Дата:
"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

От:
mudfoot@rawbw.com
Дата:
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
> 
> 


Re: [JDBC] Performance problem using V3 protocol in jdbc driver

От:
Csaba Nagy <nagy@ecircle-ag.com>
Дата:
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
> 
> 

FAQ