I've found many of developers using like with '%' and allowing application user to fetch all rows in table. For example consider query like this:
select * from ms_account where customer_name like '%'||:p_1||'%'
When the users submit the query using a,b or % only, the database will query all the records and could cause very high consumption server resources (Memory, I/O, CPU)
Using rownum could help.
select * from ms_account where customer_name like '%'||:P_1||'%' and rownum <= 10. This will fetch the query with maximum 10 records.
Learn more about rownum : http://www.oracle.com/technology/oramag/oracle/06-sep/o56asktom.html
You should limit your query (espesially the one with LIKE)
Disclaimer
The views expressed on this blog are my own and do not necessarily reflect the views of Oracle.
Tuesday, April 29, 2008
Thursday, January 3, 2008
Oracle Forms vs Oracle ADF
I've been using Oracle Forms/Reports for about 5 years,with all of its pros and cons. About 2 years ago, i have opportunity to implement my j2ee skill using Oracle ADF Swing,JSP and ADF Business components. It was a great learning experience. Right now, with EJB 3.0 released, i research more into ADF Toplink and ADF Faces to accelerate my skill set.
My opinion is:
1.Use Oracle Forms wisely. You have to understand the network requirement that could impact your application performance and the architecture flexibility. We can not configure cluster for Oracle Forms. You have to buy Load Balancer, either hardware or software to achieve high availability.
2.Use Oracle ADF to gain more flexibility in designing your application. With this framework, you have a lot of flexibility from choosing persistence technology to the client type. Oracle ADF has excellent data binding features. You can use different persistence technology ie. Toplink,ADF BC, Flat files, XML, etc. and display it using the same client code or reversely you can used your persistence component to different client type ie. web apps, swing, mobile.
Use the tools wisely and carefully...... "flexibility comes with complexity" :)
My opinion is:
1.Use Oracle Forms wisely. You have to understand the network requirement that could impact your application performance and the architecture flexibility. We can not configure cluster for Oracle Forms. You have to buy Load Balancer, either hardware or software to achieve high availability.
2.Use Oracle ADF to gain more flexibility in designing your application. With this framework, you have a lot of flexibility from choosing persistence technology to the client type. Oracle ADF has excellent data binding features. You can use different persistence technology ie. Toplink,ADF BC, Flat files, XML, etc. and display it using the same client code or reversely you can used your persistence component to different client type ie. web apps, swing, mobile.
Use the tools wisely and carefully...... "flexibility comes with complexity" :)
Saturday, March 10, 2007
How to enable load balance stateful session bean ?
Hi..recently one of my customer need to setup load balance for their ejb java applicationbuilt using JDeveloper,ADF technology ( ADF JClient ).They're looking for how to setup load balance between 2 ejb containers.
Finally i've found out that you have to set
'LoadBalanceOnLookup=true' property.
and to really load balance the method call, you have to re-create the InitialContexteach time when calling the ejb method.I know it may quite impact on performance,hopefully OC4J team in next release can enhance this.
This is the implementation with ADF Business Component.You can create your customize strategy class like this :
public class Test {
private static final String EJB_BEAN_NAME = "AppModule2Bean";
public static ApplicationModule getAppModule()
{
try
{
Context ctx = getContext();
AppModule2Home home = (AppModule2Home) ctx.lookup(EJB_BEAN_NAME);
ApplicationModule am = ApplicationModuleProxy.create(home,null /* or some client props */);
am.getTransaction().connectToDataSource(null, "jdbc/Scott1DS", false); return am; }
catch (NamingException nex) { return null; } }
private static InitialContext getContext() {
try {
Hashtable env = new Hashtable();
env.put(Context.INITIAL_CONTEXT_FACTORY,"com.evermind.server.rmi.RMIInitialContextFactory"); env.put(Context.SECURITY_PRINCIPAL, "admin");
env.put(Context.SECURITY_CREDENTIALS, "welcome");
env.put("LoadBalanceOnLookup","true");
env.put("dedicated.rmicontext","true");
/* * PUT YOUR CUSTOM lookup: URL HERE */
env.put(Context.PROVIDER_URL, "ormi://rputra-id:23791/ProjectEJB1,ormi://rputra-id:23792/ProjectEJB1");
return new InitialContext(env); }
catch (NamingException e) { e.printStackTrace(); return null; } }}
public class CustomConnectionStrategy extends DefaultConnectionStrategy{
public CustomConnectionStrategy(){ }
public ApplicationModule createApplicationModule(Hashtable p0) {
JUApplication app = new JUApplication(Test.getAppModule());
AppModule2 appMod = (AppModule2)app.getApplicationModule();
return appMod;
}
}
and then in your ADF Application Module Configuration Manager (right click Application Module, choose Configuration),pick one of your configuration name and set this
jbo.ampool.connectionstrategyclass = 'your CustomConnectionStrategy class name'
that's it your j2ee application now is load balance enabled.
Hi..recently one of my customer need to setup load balance for their ejb java applicationbuilt using JDeveloper,ADF technology ( ADF JClient ).They're looking for how to setup load balance between 2 ejb containers.
Finally i've found out that you have to set
'LoadBalanceOnLookup=true' property.
and to really load balance the method call, you have to re-create the InitialContexteach time when calling the ejb method.I know it may quite impact on performance,hopefully OC4J team in next release can enhance this.
This is the implementation with ADF Business Component.You can create your customize strategy class like this :
public class Test {
private static final String EJB_BEAN_NAME = "AppModule2Bean";
public static ApplicationModule getAppModule()
{
try
{
Context ctx = getContext();
AppModule2Home home = (AppModule2Home) ctx.lookup(EJB_BEAN_NAME);
ApplicationModule am = ApplicationModuleProxy.create(home,null /* or some client props */);
am.getTransaction().connectToDataSource(null, "jdbc/Scott1DS", false); return am; }
catch (NamingException nex) { return null; } }
private static InitialContext getContext() {
try {
Hashtable env = new Hashtable();
env.put(Context.INITIAL_CONTEXT_FACTORY,"com.evermind.server.rmi.RMIInitialContextFactory"); env.put(Context.SECURITY_PRINCIPAL, "admin");
env.put(Context.SECURITY_CREDENTIALS, "welcome");
env.put("LoadBalanceOnLookup","true");
env.put("dedicated.rmicontext","true");
/* * PUT YOUR CUSTOM lookup: URL HERE */
env.put(Context.PROVIDER_URL, "ormi://rputra-id:23791/ProjectEJB1,ormi://rputra-id:23792/ProjectEJB1");
return new InitialContext(env); }
catch (NamingException e) { e.printStackTrace(); return null; } }}
public class CustomConnectionStrategy extends DefaultConnectionStrategy{
public CustomConnectionStrategy(){ }
public ApplicationModule createApplicationModule(Hashtable p0) {
JUApplication app = new JUApplication(Test.getAppModule());
AppModule2 appMod = (AppModule2)app.getApplicationModule();
return appMod;
}
}
and then in your ADF Application Module Configuration Manager (right click Application Module, choose Configuration),pick one of your configuration name and set this
jbo.ampool.connectionstrategyclass = 'your CustomConnectionStrategy class name'
that's it your j2ee application now is load balance enabled.
Subscribe to:
Posts (Atom)