Harshad <harshad...@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

Reply via email to