Re: [SQL] Multicolum index and primary key

2003-11-18 Thread Michele Bendazzoli
On Mon, 2003-11-17 at 18:13, Tomasz Myrta wrote: > Dnia 2003-11-17 19:00, Użytkownik Michele Bendazzoli napisał: > > a is always present in the queries ... and other that (a, ab, abc) i > > have only to query (ac): so I think I have to index separately only > > (ac). > > For such cases consider ch

Re: [SQL] Multicolum index and primary key

2003-11-17 Thread Michele Bendazzoli
On Mon, 2003-11-17 at 17:23, Rod Taylor wrote: > > Suppose by example that one have a table1 with a primary key over three > > field (a, b, c): > .. > > are the indexes over (a) and (a, b) redundant (and so useless)? > > Yes, they are redundant not not necessarily useless. > > In short, an index

Re: [SQL] Multicolum index and primary key

2003-11-17 Thread Michele Bendazzoli
On Mon, 2003-11-17 at 17:14, Peter Eisentraut wrote: > Michele Bendazzoli writes: > > > ALTER TABLE public.table1 > > ADD CONSTRAINT table1_pkey PRIMARY KEY(a, b, c); > > > > are the indexes over (a) and (a, b) redundant (and so useless)? > > Exactly. > > p.s. I know, I'll have to begin to use

Re: [SQL] Multicolum index and primary key

2003-11-17 Thread Michele Bendazzoli
On Mon, 2003-11-17 at 17:15, Tomasz Myrta wrote: > Dnia 2003-11-17 18:00, Użytkownik Michele Bendazzoli napisał: > > p.s. I know, I'll have to begin to use the explain command ... > > I promise I'll do it ;-) > > Use the explain analyze command and then answer yourself ;-) I'm not in still in pro

Re: [SQL] Multicolum index and primary key

2003-11-17 Thread Rod Taylor
> Suppose by example that one have a table1 with a primary key over three > field (a, b, c): .. > are the indexes over (a) and (a, b) redundant (and so useless)? Yes, they are redundant not not necessarily useless. In short, an index with 3 keys will be larger than an index with 1 key, as such

Re: [SQL] Multicolum index and primary key

2003-11-17 Thread Tomasz Myrta
Dnia 2003-11-17 18:00, Użytkownik Michele Bendazzoli napisał: p.s. I know, I'll have to begin to use the explain command ... I promise I'll do it ;-) Use the explain analyze command and then answer yourself ;-) Regards, Tomasz Myrta ---(end of broadcast)

Re: [SQL] Multicolum index and primary key

2003-11-17 Thread Peter Eisentraut
Michele Bendazzoli writes: > ALTER TABLE public.table1 > ADD CONSTRAINT table1_pkey PRIMARY KEY(a, b, c); > > are the indexes over (a) and (a, b) redundant (and so useless)? Exactly. > p.s. I know, I'll have to begin to use the explain command ... > I promise I'll do it ;-) You could also hav

[SQL] Multicolum index and primary key

2003-11-17 Thread Michele Bendazzoli
I wonder if is useless to set some indexes for columns contained in a multifield primary key. Suppose by example that one have a table1 with a primary key over three field (a, b, c): ALTER TABLE public.table1 ADD CONSTRAINT table1_pkey PRIMARY KEY(a, b, c); are the indexes over (a) and (a, b)