Hi!
I've got following structure:
CREATE TABLE test ( field1 int8 );
CREATE INDEX test_ndx ON test USING btree (field1);
But when I execute following Java code:
PreparedStatement pstmt = con.prepareStatement("SELECT field1 FROM
test WHERE field1=?;");
pstmt.setLong(1, 1);
pstmt.executeQuery();
it doesn't use created index.
When I change my code:
PreparedStatement pstmt = con.prepareStatement("SELECT field1 FROM
test WHERE field1=int8(?);");
pstmt.setLong(1, 1);
pstmt.executeQuery();
then it uses index.
My question is: Shouldn't JDBC Driver automatically cast type basing on
methods setLong, setInt etc. ? You can say: "Change your code, what's
your problem?". But I don't know which database I will use and not all
databases has int8() functions (I think so.). If you know what i mean.
Can you help me ?
P.S. I'm using PostgreSQL 7.3 with last PgSQL JDBC3 Driver.
"PostgreSQL Native Driver (ver.:PostgreSQL 7.3 JDBC3 jdbc driver build
106)"
--
Best regards,
Marek Kaluzny