incubator-empire-db-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From McKinley <mckinley1...@gmail.com>
Subject Best way to Generate SQL String For JDBC?
Date Fri, 22 Jan 2010 15:44:29 GMT
In a web application I want to create highly visited web pages that
will be a user home page. I want to reduce the processing time it
takes to generate every last detail on the page including generating a
query through Empire-db. I would like to cache it as follows:

Now, I know that Empire-db will not be the bottleneck in this type of
application. But, I will need to shave off as many 50ms and 100ms
operations as I can for just this one user page. I will even be
caching HTML headers and footers at the HTTP level so that only
dynamic content gets processed through Java. I will be caching the
rendered database output for the last x number of popular users too.

I want to do something like the following and use Empire-db for the
really command creation, but then cache that string and use it with
JDBC directly to eliminate as much overhead as possible.

String sqlUserHomePageCmd =
(String)someApplicationStateCache.get("sqlUserHomePageCmd");
if(sqlUserHomePageCmd == null) {
    cmd.clear();
    cmd.select(posts.CommentID, post.CommentText);
    cmd.select(post.CommentDate, post.ThreadTitle);
    // cmd.where(post.UserID.is(someSessionState.getUserID()));
    cmd.where(post.UserID.is("?")); // Don't do the above, but make it
a prepared statement string
    sqlUserHomePageCmd = cmd.getSelect();
    someApplicationStateCache.put(sqlUserHomePageCmd);
}

PrepareStatment ps = conn.prepareStatment(someApplicationStateCache);
ps.setInt(0, someSessionState.getUserID());
...

Thanks,

McKinley

Mime
View raw message