db-derby-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Knut Anders Hatlen <Knut.Hat...@Sun.COM>
Subject Re: Performance issue of derby using JDBC
Date Mon, 22 Dec 2008 21:15:09 GMT
Harshad <harshad.rj@gmail.com> writes:

> Thanks Mike & Kristian for the tips on indexes.
>
> Creating an index on multiple columns in my DB does indeed speed up
> the original query, so Yay!
>
> It would have been even cooler if I could just declare that
> combination of two columns will be unique, rather than create an index
> (with its associated overheads). (I am assuming that in this instance
> the actual index is not useful to the optimiser)

Actually you can declare that the combination of two columns is unique,
like this:

  CREATE TABLE T (X INT, Y INT, Z INT, UNIQUE(X,Y))

Derby will still create an index, though, since it needs an efficient
way to check that no duplicates are introduced by INSERT or UPDATE
statements. But you don't need to issue a CREATE INDEX statement
yourself.

-- 
Knut Anders

Mime
View raw message