Off-the-shelf JVMs, and thus the PCA/JVM, benefit from advances in JVM capabilities and significant optimizations so that they are considerably faster than the internal JVM in Adaptive Server 15.0.2 and earlier. However, propagating a SQL call into Java can still create a bottleneck that can be even more pronounced with the PCA/JVM.
To take advantage of the speed of the PCA/JVM, minimize the number of calls from SQL to the JVM.
Consider the simple Address class:
public class Address implements java.io.Serializable {
private int state;
private String street;
private String zip;
// ...
public Address()
{
// ...
}
public Address(String street, String zip, int state)
{
this();
this.setStreet(street);
this.setZip(zip);
this.setState(state);
}
// ,,,
public void setStreet(String street)
(
// ..
}
public void setZip(String zip)
{
// ...
}
}
Because of the overhead associated with calls into the JVM, it is significantly faster to use the three-argument constructor from SQL than the zero-argument constructor followed by the set methods for the data members. Thus, this statement:
1> declare @a Address
2> select @a=new Address("123 Elm Street", "12345", 10)
is more efficient than:
1> declare @a Adress
2> select @a = new Address()
3> select @a >> setStreet("123 Elm Street")
4> select @a >> setZip("12345")
5> select @a >> setState(10)
Pushing as much processing as possible into the Java without requiring repeated crossing of the SQL-Java interface reduces overhead and more fully exploits the improved capabilities of the JVM.