A composite index on both columns may be used by queries involving
either both columns, or the first column in the index.
http://dev.mysql.com/doc/refman/5.0/en/multiple-column-indexes.html
So, an index on (receiver_id, sender_id) may be used by predicates on
both columns or receiver_id
3:50 AM
To: Ananda Kumar
Cc: James Tu; MySQL List
Subject: Re: index, unique index question
A composite index on both columns may be used by queries involving
either both columns, or the first column in the index.
http://dev.mysql.com/doc/refman/5.0/en/multiple-column-indexes.html
So, an index
questions? Check the forum!
http://www.databasedevelopmentforum.com
-Noah
-Original Message-
From: Kristian Myllymäki [mailto:[EMAIL PROTECTED]
Sent: Tuesday, August 14, 2007 3:50 AM
To: Ananda Kumar
Cc: James Tu; MySQL List
Subject: Re: index, unique index question
A composite index on both
-
From: Kristian Myllymäki [mailto:[EMAIL PROTECTED]
Sent: Tuesday, August 14, 2007 3:50 AM
To: Ananda Kumar
Cc: James Tu; MySQL List
Subject: Re: index, unique index question
A composite index on both columns may be used by queries involving
either both columns, or the first column
I have a table that has a Primary key using the 'id' column.
The table also has a 'receiver_id' and a 'sender_id'.
I have queries that will use
(1) WHERE receiver_id =
or
(2) WHERE sender_id=
but never WHERE receiver_id='###' AND sender_id='###'
Also, I want the receiver_id/sender_id pair to be
Hi James,
Since your queries have both receiver_id and sender_id in the where
condition and u want this to be unique, just create one combined unique
index on both these columns.
Do this at db level will give you much better options, performance, rather
than doing at code level, which might