I'm supporting a Grails web application which shows different visuals for client using AmCharts. On one of the tabs there are three charts which each return the top ten, so only ten rows, from the database based on different measures. It takes 4-5 or sometimes even more time to finish. The query runs on the DB in under 10 seconds.
The following service method is called to return results:
List fetchTopPages(params, Map querySettings, String orderClause) {
if(!((params['country'] && params['country'].size() > 0) || (params['brand'] && params['brand'].size() > 0) || (params['url'] && params['url'].size() > 0))) {
throw new RuntimeException('Filters country or brand or url not selected.')
}
Sql sql = new Sql(dataSource)
sql.withStatement { stmt -> stmt.fetchSize = 100 }
Map filterParams = acquisitionService.getDateFilters(params, querySettings)
ParamUtils.addWhereArgs(params, filterParams)
String query = "This is where the query is"
ParamUtils.saveQueryInRequest(ParamUtils.prettyPrintQuery(query, filterParams))
log.debug("engagement pageviews-by-source query: " + ParamUtils.prettyPrintQuery(query, filterParams))
List rows = sql.rows(query, filterParams)
rows
}
After some investigation it was clear that the List rows = sql.rows(query, filterParams) line is the one that takes up this load time.
Has anyone expreienced this issue before? Why is sql.rows() taking so long when it's only returning 10 rows worth of results, and the query is runnig super fast on the DB side?
Additional info:
DB: FSL1D
Running following command on DB side: java -jar ojdbc5.jar - getversion returns:
"Oracle 11.2.0.3.0 JDBC 3.0 compiled with JDK5 on Thu_Jul_11_15:41:55_PDT_2013
Default Connection Properties Resource
Wed Dec 16 08:18:32 EST 2015"
Groovy Version: 2.3.7 Grails Version: 2.4.41 JDK: 1.7.0
java -jar ojdbc5.jar - getversionreturns: Oracle 11.2.0.3.0 JDBC 3.0 compiled with JDK5 on Thu_Jul_11_15:41:55_PDT_2013 #Default Connection Properties Resource #Wed Dec 16 08:18:32 EST 2015 Groovy Version: 2.3.7 Grails Version: 2.4.41 JDK: 1.7.0 - krizsa