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

 

 

Reply via email to