You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Yair Lenga (JIRA)" <ji...@apache.org> on 2016/12/27 16:24:58 UTC

[jira] [Updated] (DBUTILS-131) Speedup query calls without parameters

     [ https://issues.apache.org/jira/browse/DBUTILS-131?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Yair Lenga updated DBUTILS-131:
-------------------------------
    Attachment: QueryRunner-query.java
                NewQueryRunner.java

Proposed change to the query method 

> Speedup query calls without parameters
> --------------------------------------
>
>                 Key: DBUTILS-131
>                 URL: https://issues.apache.org/jira/browse/DBUTILS-131
>             Project: Commons DbUtils
>          Issue Type: Improvement
>    Affects Versions: 1.6
>            Reporter: Yair Lenga
>         Attachments: NewQueryRunner.java, QueryRunner-query.java
>
>
> The current 'query' methods takes sql (with ? placeholders), and list of parameters to fill the place holders. The implementation is using a prepared statement to speed up the call.
> I've observed that for statements without any ? placeholders, performance can be improved by using the statement interface. Using this path eliminate extra roundtrip and work that is needed to create the prepared statement (I believe it's implemented - on Sybase - as light weight stored proc). 
> My proposal: modify the code in the method that implement the query:
> private <T> T  [More ...] query(Connection conn, boolean closeConn, String sql, ResultSetHandler<T> rsh, Object... params)
> and use 'Statement', instead of preparedStatement if there are no params (params == null || params.size() == 0 )
> In my application, large number of (parameter-less) SQL statement are generated on-the-fly, and the result set is converted to BeanList. We measured 50% speedup using statements, instead of prepared statements for this case.
> We will be happy to submit a fix or help with testing.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)