View Single Post

   
  #3 (permalink)  
Old 02-28-2008, 11:29 AM
Abandoned
 
Posts: n/a
Default Re: Which index can i use ?

On Oct 28, 3:27 pm, "Paul Lautman" <paul.laut...@btinternet.com>
wrote:
> Abandoned wrote:
> > Hi..
> > I want to do index in database.
> > My table:
> > id(int) | id2(int) | w(int) | d(int)

>
> > My query:
> > select id, w where id=x and id2=y (sometimes and d=z)

>
> > I have too many insert and select operation on this table.
> > And which index type can i use ? Btree, Rtree, Gist or Hash ?
> > Also I want to unique (id, id2)..
> > Now this is my index. is it give me good performance ?
> > CREATE UNIQUE INDEX ind1 ON test USING btree (id, id2)
> > CREATE INDEX ind2 ON test USING btree (id)
> > CREATE INDEX ind3 ON test USING btree (id2)
> > CREATE INDEX ind4 ON test USING btree (w)
> > CREATE INDEX ind5 ON test USING btree (d)

>
> > I'm too sorry my bad english.
> > King regards..

>
> If you only ever use d=z in conjunction with id=x and id2=y, then I would go
> for a single index of
> (id, id2, d).
> Depending on the structure of your data, you might simply make this the only
> index (primary key).


Which is the give me better performance ?
Single (id, id2)
or two different index (id) (id2) ?
And how about unique ?

Reply With Quote