Subject Re: [Firebird-Java] jabird / Select / Update
Author Mark Rotteveel
On 19-11-2012 16:54, Steffen Heil (Mailinglisten) wrote:
> Hi
> We are updating a (possibly) huge table with a statement like this:
> Statement statement = connection.createStatement(
> java.sql.ResultSet.CONCUR_UPDATABLE );
> ResultSet data = statement.executeQuery( "select id, q from t where q is not
> null" );
> while ( ) {
> String q = data.getString( 2 );
> data.updateString( 2, modify( q ) );
> data.updateRow();
> }
> data.close();
> statement.close();
> Now I need to be sure, that those changes are done during that loop and are
> not cached by jaybird and executed afterwards.
> Because there may be much more entries that available memory.

At the moment you call updateRow(), Jaybird will execute a query to
update that row in Firebird (see the code in
org.firebirdsql.jdbc.FBRowUpdater )

> If there is any way to optimize that loops behavior, feel free to comment.
> (id is the primary key of that table, q in the example is a varchar(200).)

You could go with the suggestion by the_a_rioch earlier today to use two
separate (Prepared)Statement objects. It is slightly more work for you,
but it replaces the heuristics of the driver to update the right row
with an explicit query. Although performance and memory wise it will
probably not make a lot of difference.


Mark Rotteveel