| Register | FAQ | Calendar | Search | Today's Posts | Mark Forums Read |
|
#1
| |||
| |||
| I'm proud and certified Java programmer since 1998. Trust me, a lot of experience! And I prefer Java. Also I work with other languages too. For example we support/develop big system with around 300 perl scripts. I try to move them to Java, but... Recently I tried port one perl script. It does nothing but creates thousands SQLs retrieve and store/summarize rezults. SQLs are complicated a little but return only pair of values. And this pair is stored in hashtable. That's all. Simple enough. Why not to rewrite? But in Java it runs at least twice slower! In my understanding there is no Java/perl calculations. Store couple values! Phoo! All time, I assume, is wasted on Oracle 9 connection. In middleware. The SQLs are the same, connection is the same, Oracle is the same, machine is the same. Everything is the same. Except time. perl is faster somehow. Then I used prepared statements. It became worse. At least 2.5 times slower... What's the deal? Any ideas why it happens? I believe I use latest Java 1.4, JDBC (ojdbc14.jar) from Oracle as well as latest perl DBD or Oraperl modules. Who have better experience? Alex Kizub. |
|
#2
| |||
| |||
| <akizub@yahoo.com> a écrit dans le message de news:1107099254.043334.7470@c13g2000cwb.googlegrou ps.com... > I'm proud and certified Java programmer since 1998. > Trust me, a lot of experience! And I prefer Java. > Also I work with other languages too. > For example we support/develop big system with around 300 perl scripts. > I try to move them to Java, but... > > Recently I tried port one perl script. It does nothing but creates > thousands SQLs > retrieve and store/summarize rezults. SQLs are complicated a little but > return only pair of values. And this pair is stored in hashtable. > That's all. Simple enough. > > Why not to rewrite? > But in Java it runs at least twice slower! > In my understanding there is no Java/perl calculations. Store couple > values! Phoo! > > All time, I assume, is wasted on Oracle 9 connection. In middleware. > The SQLs are the same, connection is the same, Oracle is the same, > machine is the same. Everything is the same. Except time. perl is > faster somehow. > > Then I used prepared statements. It became worse. At least 2.5 times > slower... > What's the deal? > Any ideas why it happens? > > I believe I use latest Java 1.4, JDBC (ojdbc14.jar) from Oracle as well > as latest perl DBD or Oraperl modules. > Who have better experience? > > Alex Kizub. > Do you use Connection pool ? maybe the time involved is lost in connecting all the time K |
|
#3
| |||
| |||
| One connection. Always alive. All these hours ((Alex Kizub |
|
#4
| |||
| |||
| <akizub@yahoo.com> schrieb im Newsbeitrag news:1107108668.029243.67800@c13g2000cwb.googlegro ups.com... > One connection. Always alive. All these hours ((> Alex Kizub If the SQL is exactly the same and you used the same machine for boths tests the most likely cause is probably your Java code. Did you profile it? robert |
|
#5
| |||
| |||
| 100% |
|
#6
| |||
| |||
| akizub@yahoo.com said: >Recently I tried port one perl script. It does nothing but creates >thousands SQLs retrieve and store/summarize rezults. SQLs are >complicated a little but return only pair of values. And this pair is >stored in hashtable. That's all. Simple enough. > >Why not to rewrite? >But in Java it runs at least twice slower! If I recall correctly, JDBC will at some point do conversion from the database character set to Unicode - and perl will not, unless your environment is set up to use/require use of UTF8 character encoding. This could be at least part of what you're seeing. Are your programs CPU-bound? That is, are they using (almost) one second of CPU time for each wallclock second? If so, that'd sound even more like the problem would be in character set conversions. Btw, is it the JDBC thin driver you're using? You might wish to compare results when using JDBC OCI driver; there could be a difference. The perl DBD::Oracle driver uses the OCI driver layer anyway. -- Wolf a.k.a. Juha Laiho Espoo, Finland (GC 3.0) GIT d- s+: a C++ ULSH++++$ P++@ L+++ E- W+$@ N++ !K w !O !M V PS(+) PE Y+ PGP(+) t- 5 !X R !tv b+ !DI D G e+ h---- r+++ y++++ "...cancel my subscription to the resurrection!" (Jim Morrison) |
|
#7
| |||
| |||
| akizub@yahoo.com sez: .... > All time, I assume, is wasted on Oracle 9 connection. In middleware. > The SQLs are the same, connection is the same, Oracle is the same, > machine is the same. Everything is the same. Except time. perl is > faster somehow. > > Then I used prepared statements. It became worse. At least 2.5 times > slower... > What's the deal? > Any ideas why it happens? Oracle's JDBC driver is very fast -- I have a Java program that uses prepared statements to bulk-load data from text file, it's as fast as using oracle loader. You can reasonably expect Java to be a little slower, but not much. A 2.5 times slowdown with prepared statements is a sure sign that your code is broken. Dima -- Things seemed simpler before we kept computers. -- IX, Revelation |
|
#8
| |||
| |||
| <akizub@yahoo.com> wrote in message news:1107099254.043334.7470@c13g2000cwb.googlegrou ps.com... > I'm proud and certified Java programmer since 1998. > Trust me, a lot of experience! And I prefer Java. > Also I work with other languages too. > For example we support/develop big system with around 300 perl scripts. > I try to move them to Java, but... > > Recently I tried port one perl script. It does nothing but creates > thousands SQLs > retrieve and store/summarize rezults. SQLs are complicated a little but > return only pair of values. And this pair is stored in hashtable. > That's all. Simple enough. > > Why not to rewrite? > But in Java it runs at least twice slower! > In my understanding there is no Java/perl calculations. Store couple > values! Phoo! > > All time, I assume, is wasted on Oracle 9 connection. In middleware. > The SQLs are the same, connection is the same, Oracle is the same, > machine is the same. Everything is the same. Except time. perl is > faster somehow. > > Then I used prepared statements. It became worse. At least 2.5 times > slower... > What's the deal? > Any ideas why it happens? > > I believe I use latest Java 1.4, JDBC (ojdbc14.jar) from Oracle as well > as latest perl DBD or Oraperl modules. > Who have better experience? > > Alex Kizub. > Yes, I would have to take a look at the code of the Java application. Was the original PERL script hitting an Oracle database? Why are you calling thousands of SQL statements that just return a pairs? Is there any way to call several of these statements in a single call? PERL is great for text manipulation, but I don't think this fact would cover the gammut of ~2.5x difference in speed. Did you run an explain plan on your Oracle SQL? Is your Oracle box the same DB that the perl scripts are calling? (Ie perl hitting production, java hitting some crappy 90mhz oracle box someone threw together). Are you using SQL hints when tuning your SQL? When you step through a debug, are the SQL calls taking the most time? Are you using the same Oracle client software on both test scenarios? Are you using a persistant connection? (ie not dropping and reconnecting every script). Are you creating a Java application for every script, or are you creating a large single Java app that calls all scripts? I don't want the answers to all these, just suggesting some things to try. I know you said you were using the same Oracle, but if all you are doing is sending a SQL statement to Oracle, Java is done until you get the result. It doesn't sound the same. By same I mean you are connecting to the same server, same instance with the same client on the same workstation, just two different languages. Does your workstation have enough free memory to be running Java? On OraclePower.com (ya ya, shameless plug, but I *do* have a point) I run 17 queries on the home page, and it comes back instantly. Oracle hauls-ass with Java. -- Tom Dyess OraclePower.com |
|
#9
| |||
| |||
| On Mon, 31 Jan 2005 03:45:08 +0800, Dimitri Maziuk wrote (in article <slrncvqea4.cgb.dima@localhost.localdomain>): > akizub@yahoo.com sez: > ... >> All time, I assume, is wasted on Oracle 9 connection. In middleware. >> The SQLs are the same, connection is the same, Oracle is the same, >> machine is the same. Everything is the same. Except time. perl is >> faster somehow. >> >> Then I used prepared statements. It became worse. At least 2.5 times >> slower... >> What's the deal? >> Any ideas why it happens? > > Oracle's JDBC driver is very fast -- I have a Java program that > uses prepared statements to bulk-load data from text file, it's > as fast as using oracle loader. > > You can reasonably expect Java to be a little slower, but not > much. A 2.5 times slowdown with prepared statements is a sure > sign that your code is broken. > > Dima > oracles jdbc is not fast, it is a piece of crap. try using 1. the demo version from datadirect ,it is good for 15 days, but will allow you to bench mark 2. try using the thin driver from java. 3. post your code ( minus passwords & domain), ill take a look. steve |
|
#10
| |||
| |||
| <akizub@yahoo.com> wrote: > 100% Huh? Do you mean it's using 100% of the CPU? If so, then you *definitely* need to aquire a profiler and figure out where that time is being spent. It shouldn't be taking nearly so long to issue queries. There are a number of mistakes you could be making, but without seeing your code or your profiling results, there's little that we can do. -- www.designacourse.com The Easiest Way To Train Anyone... Anywhere. Chris Smith - Lead Software Developer/Technical Trainer MindIQ Corporation |
![]() |
| Thread Tools | |
| Display Modes | |
In an effort to better serve ads to our visitors, cookies are used on objectmix.com. For more information, check out our Privacy Policy.