Hi.

I have a performance problem with prepared statements (JDBC prepared statement).

This query:

PreparedStatement st = conn.prepareStatement("SELECT id FROM dga_dienstleister WHERE plz like '45257'");

does use an index.

This query:

        String plz = "45257";
PreparedStatement st = conn.prepareStatement("SELECT id FROM dga_dienstleister WHERE plz like ?");
        st.setString(1, plz);

does NOT use an index.

As it should in the end result in absolutely the same statement, the index should be used all the time. I have to set the protocolVersion=2 and use the JDBC2 driver to get it working (but then the statements are created like in the first query, so no solution, only a workaround).

I'm not sure whether this is a bug (I think it is) or a problem of understanding.

Known problem?

I have tried PG 8.0.1, 8.0.3, 8.1beta with the JDBC-drivers

- postgresql-8.0-312.jdbc2.jar --> okay with protocolVersion=2 in the URL
- postgresql-8.0-312.jdbc3.jar --> not okay whatever I do

I'm on Mac OS X, if that matters.

cug

---------------------------(end of broadcast)---------------------------
TIP 1: if posting/reading through Usenet, please send an appropriate
      subscribe-nomail command to [EMAIL PROTECTED] so that your
      message can get through to the mailing list cleanly

Reply via email to