This makes a lot of sense now - I haven't read up on the C interface and assumed that "step" was a JDBC thing. Thanks for clearing that up.
George. On 09/26/2009 01:01 AM, Pavel Ivanov wrote: >> Does anyone know why this method might be so expensive? >> > Because it's main method to execute your queries. > I believe I can safely assume that org.sqlite.NativeDB.step maps > directly to C call sqlite3_step() and it's the only function where > query is executed. It doesn't just iterate through resultset it > obtains this resultset it too. > > Pavel > > On Thu, Sep 24, 2009 at 11:24 PM, George Bills<gbi...@funnelback.com> wrote: > >> Hi everyone - this might be a general JDBC question rather than an >> SQLite specific question, but I'm not sure. >> >> I've got an app that's writing to an SQLite database using the latest >> SQLite JDBC driver ("v056, based on SQLite 3.6.14.2") from >> http://www.zentus.com/sqlitejdbc/. >> >> I've done some basic profiling using hprof, and initially things are >> fine. But then my tables get quite large (e.g. 26 million / 7 million / >> 6 million rows), and after this point, I find that a huge amount of my >> apps time is being spent in "org.sqlite.NativeDB.step". >> >> Does anyone know why this method might be so expensive? I probably need >> to dig deeper with my profiling and find out exactly which methods are >> calling the expensive "step"s, but I'm fairly new to working with JDBC >> and any hints or suggestions would be helpful. >> >> During the applications run, I'll be running a certain amount of selects >> and inserts, but in all cases, I'll be selecting or inserting 1 row at a >> time, so I wouldn't expect that iterating over my ResultSet (I assume >> this is what org.sqlite.NativeDB.step is doing) would be very expensive. >> >> The code that does the selection of a row, given an SQL string and an >> array of string parameters is like: >> >> selectStatement = databaseConnection.prepareStatement(SQL); >> setStatementParameters(selectStatement, parameters); >> resultSet = selectStatement.executeQuery(); >> singleResult = parseResultForSingleElement(resultSet, >> columnName); >> >> The code that does the insertion of a row, given an SQL string and an >> array of string parameters is like: >> >> insertStatement = databaseConnection.prepareStatement(SQL); >> setStatementParameters(insertStatement, parameters); >> insertStatement.executeUpdate(); >> resultSet = insertStatement.getGeneratedKeys(); >> autoincrementPK = parseResultForSingleElement(resultSet, null); >> >> parseResultForSingleElement is like: >> >> if (numColumns == 1&& res.next()) { >> E val; >> if (columnName != null) { >> val = (E) res.getObject(columnName); >> } else { >> val = (E) res.getObject(1); >> } >> if (res.wasNull()) { >> ret = new SQLVal<E>(ResultStatus.RESULT_WAS_NULL); >> } else { >> ret = new SQLVal<E>(val); >> } >> } >> >> Thanks for any help. >> George. >> _______________________________________________ >> sqlite-users mailing list >> sqlite-users@sqlite.org >> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users >> >> > _______________________________________________ > sqlite-users mailing list > sqlite-users@sqlite.org > http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users > _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users