Thread: Multiple column indexes

Multiple column indexes

From
Garth Keesler
Date:
I have a primary key made up of two varchar(128) columns, typically less
than 16 chars each. Concatenating the two columns would still be unique.
Would it make sense to concat the two columns, using a unique separator
like '~' and index on that single column or would that be more trouble
than the potential performance gains?

Thanx,
Garth

Re: Multiple column indexes

From
"Merlin Moncure"
Date:
On 1/19/07, Garth Keesler <garthk@gdcjk.com> wrote:
> I have a primary key made up of two varchar(128) columns, typically less
> than 16 chars each. Concatenating the two columns would still be unique.
> Would it make sense to concat the two columns, using a unique separator
> like '~' and index on that single column or would that be more trouble
> than the potential performance gains?

yes. use a multiple key index. that is what they are for. or let the
db do it for you:

create table foo (a text, b text, primary key(a,b));

merlin

Re: Multiple column indexes

From
Garth Keesler
Date:
I thought as much.

Thanx for the reply,
Garth

Merlin Moncure wrote:
> On 1/19/07, Garth Keesler <garthk@gdcjk.com> wrote:
>> I have a primary key made up of two varchar(128) columns, typically less
>> than 16 chars each. Concatenating the two columns would still be unique.
>> Would it make sense to concat the two columns, using a unique separator
>> like '~' and index on that single column or would that be more trouble
>> than the potential performance gains?
>
> yes. use a multiple key index. that is what they are for. or let the
> db do it for you:
>
> create table foo (a text, b text, primary key(a,b));
>
> merlin
>
> ---------------------------(end of broadcast)---------------------------
> TIP 6: explain analyze is your friend
>
> .
>