Welcome to dbFreaks.com!
FAQFAQ    SearchSearch      ProfileProfile    Private MessagesPrivate Messages   Log inLog in

JDBC Performance is no where near .NET performance (JDBC 1..

 
   Database Help (Home) -> JDBC Driver RSS
Next:  SQL Express Advanced  
Author Message
JustCycling

External


Since: May 28, 2008
Posts: 2



(Msg. 1) Posted: Wed May 28, 2008 10:21 am
Post subject: JDBC Performance is no where near .NET performance (JDBC 1.2 against mssql2008)
Archived from groups: microsoft>public>sqlserver>jdbcdriver (more info?)

I am finding that the adaptive buffering returns rows at the same rate as
the server side cursor. It may improve client memory footprint on large
resultsets but I cannot seem to get performance up to the level of a similar
app written in .NET using SqlDataReader classes. The JDBC performance is
really bad. This only seems to be an issue in the large resultset scenario
which is what we deal with in our product.

My test app creates 6 threads, each with their own connection to the same
SQL Server instance, query different tables with the same replicated data.
The resultset will return 83,000 rows of 17 columns of data (a good mix of
data types...no blobs). The app will loop through every row and column but
do nothing with the data, except reading it.

JDBC averages 79.0 seconds
..NET averages 0.90 seconds

Any ideas?

Here is a snippet of the java thread test code:
....
Connection c = DriverManager.getConnection("jdbc:sqlserver://" + host +
":1433;databaseName=" + database + ";user=" + user +
";password=" + password +
";responseBuffering=adaptive;");

// Statement stmt = c.createStatement();
Statement stmt =
c.createStatement(SQLServerResultSet.TYPE_SS_SERVER_CURSOR_FORWARD_ONLY,
SQLServerResultSet.CONCUR_READ_ONLY);

((SQLServerStatement) stmt).setResponseBuffering("adaptive");
ResultSet rs = stmt.executeQuery(sql);
rs.setFetchSize(10000);

ResultSetMetaData rsMetaData = rs.getMetaData();
int numberOfColumns = rsMetaData.getColumnCount();

String tempVar;
int rowCounter = 0;

// loop through rows in resultset
while (rs.next()) {
// loop all columns and read value
for (int i=1; i<numberOfColumns; i++) {
tempVar = rs.getString(i);
}

rowCounter += 1;
}
....
Is the JDBC code that much different at the TDS protocol than .NET? Any
suggestions to improve this would be great!

Thanks

 >> Stay informed about: JDBC Performance is no where near .NET performance (JDBC 1.. 
Back to top
Login to vote
David Olix

External


Since: Feb 19, 2008
Posts: 7



(Msg. 2) Posted: Tue Jun 03, 2008 8:56 pm
Post subject: RE: JDBC Performance is no where near .NET performance (JDBC 1.2 against mssql2008) [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Hi,

If you use a server cursor then adaptive buffering is defeated except with
forward only updatable result sets. But why are you using a server cursor
here? Your code looks like it just needs a standard default forward only
read only result set. That is, it should be sufficient just to create the
statement with:

Statement stmt = c.createStatement();

In that case, you also don't need to set adaptive buffering at the
Statement level, since you already set it in the connection properties.

Hope this helps (let me know if it doesn't),
--David Olix [SQL Server]

 >> Stay informed about: JDBC Performance is no where near .NET performance (JDBC 1.. 
Back to top
Login to vote
JustCycling

External


Since: May 28, 2008
Posts: 2



(Msg. 3) Posted: Wed Jun 18, 2008 10:39 am
Post subject: Re: JDBC Performance is no where near .NET performance (JDBC 1.2 against mssql2008) [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Thanks David. That did make somewhat of a difference but I am still seeing
worse performance on JDBC. Although on larger resultsets like 5million row
(a worst case) the performance approaches .NET speeds for a single thread
but as I add threads the performance is linear, whereas .NET is better than
linear.

On smaller resultsets, around 84,000, the difference is quite worse. .NET
can return the rows subsecond (500ms) where JDBC is in the 3-3.5 second
range. The JDBC driver is consistently linear as you add threads where .NET
remains constant as you add threads for this size resultset.

Any ideas? Could there be a synchronized point in the jdbc code that is
slowing it in multithreaded scenarios? I have not tried a multi-process
test to compare the timings but I will shortly.

Thanks again.


"David Olix" wrote in message

> Hi,
>
> If you use a server cursor then adaptive buffering is defeated except with
> forward only updatable result sets. But why are you using a server cursor
> here? Your code looks like it just needs a standard default forward only
> read only result set. That is, it should be sufficient just to create the
> statement with:
>
> Statement stmt = c.createStatement();
>
> In that case, you also don't need to set adaptive buffering at the
> Statement level, since you already set it in the connection properties.
>
> Hope this helps (let me know if it doesn't),
> --David Olix [SQL Server]
>
 >> Stay informed about: JDBC Performance is no where near .NET performance (JDBC 1.. 
Back to top
Login to vote
David Olix

External


Since: Feb 19, 2008
Posts: 7



(Msg. 4) Posted: Tue Jun 24, 2008 9:56 pm
Post subject: Re: JDBC Performance is no where near .NET performance (JDBC 1.2 against mssql2008) [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Hi again,

We have identified an issue with calls to Logging.getLogger possibly being
blocked/serialized. That might account for what you are seeing with
multiple threads.

We are also seeing an issue with getString/getObject on CHAR/VARCHAR
columns, which may be evident if you have many such columns in your table
schema.

Both of these issues will be addressed in the upcoming technology preview
of the v2.0 driver, due out next month. I'd like for you to give it a try
when it comes out and let me know how it works for you.

In the mean time, if you like, you can send to me at davido at microsoft
dot com the table schema and/or profiling results from running the JVM with
the -Xagentlib:hprof=cpu=samples,depth=10,file=<path to file> option
enabled, I can try to figure out whether there are any other issues.

Thanks again,
--David
 >> Stay informed about: JDBC Performance is no where near .NET performance (JDBC 1.. 
Back to top
Login to vote
Display posts from previous:   
Related Topics:
JDBC 1.2 client against SQL 2005 JDBC 2.0 server? - We need to the server-side of this driver by running xa_install.sql. The client app running on WebSphere (on an app server) will be using version 1.2 of the JDBC driver. Is it safe to install the 2.0 version on the database server, or should we stick...

New JDBC 1.2 driver runs slower than JDBC 1.1 driver-- exp.. - I have some test programs I run which do repeated simple SQL Select and SQL update statements. These test programs consistently take 5 to 10% longer to run with the new JDBC 1.2 driver than they do with the JDBC 1.1 driver. Is this expected? I..

MDX and JDBC Driver - Hi all, Anybody know if it possible to connect to an as2000 database and run mdx queries using the microsoft jdbc drivers? thanks, Peter

Which Jdbc for SQL Server 2000? - I thought I asked this question before, but I can't find it in the list so I'm trying again. I'm developing an application on Java JDSE 1.5 for Windows from Sun Microsystems. I need to connect and interact with an MS SQL Server 2000. Who's JDBC package...

Register JDBC Driver - I'm new to Java and writing a test program to connect to a SQL Server 2000 database. I read and follow the instruction in KB article # Q313100. I have modifed the Classpath statement to include the 3 jar files. How do I register the driver? In the...
   Database Help (Home) -> JDBC Driver All times are: Pacific Time (US & Canada)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You can edit your posts in this forum
You can delete your posts in this forum
You can vote in polls in this forum



[ Contact us | Terms of Service/Privacy Policy ]