List:General Discussion« Previous MessageNext Message »
From:Javier Arias Gonzalez Date:August 3 2006 10:59pm
Subject:Multiple-Column Indexes Question
View as plain text  
Assuming we have the following table:

 

CREATE TABLE test (

    id         INT NOT NULL,

    last_name  CHAR(30) NOT NULL,

    first_name CHAR(30) NOT NULL,

    PRIMARY KEY (id),

);

 

With last_name having 1,000 different values and first_name having
1000,000 different values... What is better (if any) at the time of
querying the database:

 

A)      To define an index like: "INDEX name (last_name,first_name)" and
perform a query like: "select * from test where last_name='aaa' and
first_name='bbb'"

B)      To define an index like: "INDEX name (first_name,last_name)" and
perform a query like: "select * from test where first_name='bbb' and
last_name='aaa'"

C)      It is irrelevant the order of the index definition.

 

 

Thanks in advanced

Javier

 

 


Thread
Multiple-Column Indexes QuestionJavier Arias Gonzalez4 Aug
  • Re: Multiple-Column Indexes QuestionChris4 Aug