Subject Re: Test results: JayBird vs Interclient on blob select on Linux and Windows
Author Roman Rokytskyy <rrokytskyy@acm.org>
Hi,

I have found a problem in your test case. You are executing the test
in auto-commit mode. Auto-commit mode is not the best one from the
performance point of view, because driver fetches the complete result
set locally. See my modification to your code below.

> Here it is the code:
> --------------------------------------------------------
> import java.sql.*;
>
> public class test_blob
> {
> public static void main(String args[])
> {
> for (int i=0; i<args.length; i++)
> System.out.println("args["+i+"] = "+args[i]);
> String databaseURL="", user="", password="", driverName
= "";
> user = "sysdba";
> password = "password";
> if ("win".equals(args[0])) {
> if ("fb".equals(args[1])) {
> databaseURL
= "jdbc:firebirdsql:localhost/3050:C:\\db\\test.gdb";
> driverName = "org.firebirdsql.jdbc.FBDriver";
> } else if ("ic".equals(args[1])) {
> databaseURL
= "jdbc:interbase://localhost/C:\\db\\test.gdb";
> driverName = "interbase.interclient.Driver";
> }
> } else if ("linux".equals(args[0])) {
> if ("fb".equals(args[1])) {
> databaseURL
= "jdbc:firebirdsql:localhost/3050:/home/admin/test.gdb";
> driverName = "org.firebirdsql.jdbc.FBDriver";
> } else if ("ic".equals(args[1])) {
> databaseURL
= "jdbc:interbase://localhost/home/admin/test.gdb";
> driverName = "interbase.interclient.Driver";
> }
> }
> System.out.println(driverName);
>
> Connection con;
> PreparedStatement ps;
> ResultSet rs;
> int i=0;
> byte[] bf;
> long time0 = 0, time1 = 0, time2 = 0, time3 = 0, etime = 0;
> time0 = System.currentTimeMillis();
>
> try {
> Class.forName(driverName);
> con = DriverManager.getConnection
(databaseURL,user,password);

// Here is the problem:
con.setAutoCommit(false);
// in auto-commit mode driver loads the whole
// result set in ps.executeQuery()
// this is known limitation of the driver

> String sql = "SELECT blob_field FROM TEST_TABLE";
> ps = con.prepareStatement(sql);
> time1 = System.currentTimeMillis();
> etime = time1-time0;
> System.out.println("time1 = "+etime);
>
> rs = ps.executeQuery();
> time2 = System.currentTimeMillis();
> etime = time2-time1;
> System.out.println("time2 = "+etime);
>
> while ( rs.next() ) {
> i++;
> bf = rs.getBytes(1);
> //System.out.println(i+" "+bf.length);
> }
> time3 = System.currentTimeMillis();
> etime = time3-time2;
> System.out.println("time3 = "+etime);
>
> rs.close();
> ps.close();
> con.close();
>
> }
> catch ( ClassNotFoundException cnfe )
> {
> System.err.println("Couldn't locate the driver
class: "+cnfe);
> }
> catch ( SQLException se )
> {
> System.err.println("Exception creating the database
connection: "+se);
> se.printStackTrace(System.out);
> }
> }
> }