(Disclaimer: this is a very open question, what else do I think there will be not only one correct answer, do not close it, please also consider adding answers to the community wiki)
We are working on a Play application, using Ebeanas the main ORM, while we were in dev mode on local servers, everything was pretty good. But the target environment for the application is cloud + remote SQL servers. After connecting to the target databases, we found one thing that was simply invisible in the local environment: it Ebeanexecutes separate queries many times longer than manually written ones. For instance:
Statement
This query performs a series of sub-queries for resultSetin ~ 1200 ms :
while (resultSet.next()) {
Statement innerStatement = connection.createStatement();
ResultSet innerSet
= innerStatement.executeQuery("SELECT title FROM media WHERE id='" + resultSet.getInt("id") + "'");
while (innerSet.next()) {
Logger.info("Statement: " + innerSet.getString("title"));
}
}
Ebean
~ 6500 msresultSet Ebean is required to use the same function . (the model has no relationship, so there are no associations):Media
while (resultSet.next()) {
Media media = Media.find.select("title").where().eq("id", resultSet.getInt("id")).findUnique();
Logger.info("Ebean: " + media.title);
}
Edit: the difference in the local environment is not as amazing as in general, all requests are much faster.
Of course, there are many places where series of queries can be replaced by single ones, but this is not always possible. Sometimes we need to query several different tables in one query. In other cases, we need to match thousands of records between different databases one by one, etc.
, Page<Media> Play . getList() List<Media> , ... :)
, ...
Ebean's?- (..
List Page find.where().in(..., ...) for()). ? - , Ebean (,
Page)?