I support the Grails web application, which shows various visual effects for a client using AmCharts. On one of the tabs there are three charts, each of which returns the top ten, so only ten rows from the database based on various measures. It takes 4-5, and sometimes more time. The query is executed in the database in less than 10 seconds.
The following method is called to return the 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 research, it was clear that the List rows = sql.rows(query, filterParams) is the one that takes this load time.
Has anyone else asked this problem before? Why does sql.rows () take so long when it returns only 10 rows of results, and the query is executed quickly on the DB side?
Additional Information:
DB: FSL1D
Running the following command on the DB side: java -jar ojdbc5.jar - getversion returns: "Oracle 11.2.0.3.0 JDBC 3.0 compiled from 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
source share